Type.GetTypeFromProgID メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
指定したプログラム ID (ProgID) に関連付けられている型を取得します。
オーバーロード
GetTypeFromProgID(String) |
指定したプログラム ID (ProgID) に関連付けられている型を取得し、Type の読み込み中にエラーが発生した場合は null を返します。 |
GetTypeFromProgID(String, Boolean) |
型の読み込み中にエラーが発生した場合に例外をスローするかどうかを指定して、指定したプログラム ID (ProgID) に関連付けられた型を取得します。 |
GetTypeFromProgID(String, String) |
指定したサーバーから、指定したプログラム ID (progID) に関連付けられている型を取得し、型の読み込み中にエラーが発生した場合は null を返します。 |
GetTypeFromProgID(String, String, Boolean) |
型の読み込み中にエラーが発生した場合に例外をスローするかどうかを指定して、指定したサーバーの指定したプログラム ID (ProgID) に関連付けられた型を取得します。 |
GetTypeFromProgID(String)
指定したプログラム ID (ProgID) に関連付けられている型を取得し、Type の読み込み中にエラーが発生した場合は null を返します。
public:
static Type ^ GetTypeFromProgID(System::String ^ progID);
public static Type? GetTypeFromProgID (string progID);
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static Type? GetTypeFromProgID (string progID);
[System.Security.SecurityCritical]
public static Type GetTypeFromProgID (string progID);
public static Type GetTypeFromProgID (string progID);
static member GetTypeFromProgID : string -> Type
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member GetTypeFromProgID : string -> Type
[<System.Security.SecurityCritical>]
static member GetTypeFromProgID : string -> Type
Public Shared Function GetTypeFromProgID (progID As String) As Type
パラメーター
- progID
- String
取得する型の ProgID。
戻り値
progID
がレジストリの有効なエントリで、型がそれに関連付けられている場合は、指定したクラス ProgID に関連付けられている型。それ以外の場合は null
。
- 属性
例外
progID
が null
です。
注釈
このメソッドは、COM をサポートするために用意されています。 progid は、名前空間の概念によって置き換えられているため、Microsoft .NET Framework では使用されません。
こちらもご覧ください
適用対象
GetTypeFromProgID(String, Boolean)
型の読み込み中にエラーが発生した場合に例外をスローするかどうかを指定して、指定したプログラム ID (ProgID) に関連付けられた型を取得します。
public:
static Type ^ GetTypeFromProgID(System::String ^ progID, bool throwOnError);
public static Type? GetTypeFromProgID (string progID, bool throwOnError);
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static Type? GetTypeFromProgID (string progID, bool throwOnError);
[System.Security.SecurityCritical]
public static Type GetTypeFromProgID (string progID, bool throwOnError);
public static Type GetTypeFromProgID (string progID, bool throwOnError);
static member GetTypeFromProgID : string * bool -> Type
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member GetTypeFromProgID : string * bool -> Type
[<System.Security.SecurityCritical>]
static member GetTypeFromProgID : string * bool -> Type
Public Shared Function GetTypeFromProgID (progID As String, throwOnError As Boolean) As Type
パラメーター
- progID
- String
取得する型の ProgID。
戻り値
progID
がレジストリの有効なエントリで、型がそれに関連付けられている場合は、指定したプログラム ID (ProgID) に関連付けられている型。それ以外の場合は null
。
- 属性
例外
progID
が null
です。
指定された ProgID が登録されていません。
例
次の例では、progid が無効な場合に例外をスローするかどうかを指定して、ProgID を渡すことによって型を取得します。 この例では、ProgID に関連する ClassID と、該当するすべての例外メッセージが表示されます。
using namespace System;
int main()
{
try
{
// Use the ProgID HKEY_CLASSES_ROOT\DirControl.DirList.1.
String^ myString1 = "DIRECT.ddPalette.3";
// Use a nonexistent ProgID WrongProgID.
String^ myString2 = "WrongProgID";
// Make a call to the method to get the type information of the given ProgID.
Type^ myType1 = Type::GetTypeFromProgID( myString1, true );
Console::WriteLine( "GUID for ProgID DirControl.DirList.1 is {0}.", myType1->GUID );
// Throw an exception because the ProgID is invalid and the throwOnError
// parameter is set to True.
Type^ myType2 = Type::GetTypeFromProgID( myString2, true );
}
catch ( Exception^ e )
{
Console::WriteLine( "An exception occurred." );
Console::WriteLine( "Source: {0}", e->Source );
Console::WriteLine( "Message: {0}", e->Message );
}
}
using System;
class MainApp
{
public static void Main()
{
try
{
// Use the ProgID HKEY_CLASSES_ROOT\DirControl.DirList.1.
string myString1 ="DIRECT.ddPalette.3";
// Use a nonexistent ProgID WrongProgID.
string myString2 ="WrongProgID";
// Make a call to the method to get the type information of the given ProgID.
Type myType1 =Type.GetTypeFromProgID(myString1,true);
Console.WriteLine("GUID for ProgID DirControl.DirList.1 is {0}.", myType1.GUID);
// Throw an exception because the ProgID is invalid and the throwOnError
// parameter is set to True.
Type myType2 =Type.GetTypeFromProgID(myString2,true);
}
catch(Exception e)
{
Console.WriteLine("An exception occurred.");
Console.WriteLine("Source: {0}", e.Source);
Console.WriteLine("Message: {0}", e.Message);
}
}
}
Class MainApp
Public Shared Sub Main()
Try
' Use the ProgID HKEY_CLASSES_ROOT\DirControl.DirList.1.
Dim myString1 As String = "DIRECT.ddPalette.3"
' Use a nonexistent ProgID WrongProgID.
Dim myString2 As String = "WrongProgID"
' Make a call to the method to get the type information of the given ProgID.
Dim myType1 As Type = Type.GetTypeFromProgID(myString1, True)
Console.WriteLine("GUID for ProgID DirControl.DirList.1 is {0}.", myType1.GUID.ToString())
' Throw an exception because the ProgID is invalid and the throwOnError
' parameter is set to True.
Dim myType2 As Type = Type.GetTypeFromProgID(myString2, True)
Catch e As Exception
Console.WriteLine("An exception occurred.")
Console.WriteLine("Source: {0}", e.Source.ToString())
Console.WriteLine("Message: {0}", e.Message.ToString())
End Try
End Sub
End Class
注釈
このメソッドは、COM をサポートするために用意されています。 プログラム id は、名前空間の概念によって置き換えられているため、Microsoft .NET Framework では使用されません。
こちらもご覧ください
適用対象
GetTypeFromProgID(String, String)
指定したサーバーから、指定したプログラム ID (progID) に関連付けられている型を取得し、型の読み込み中にエラーが発生した場合は null を返します。
public:
static Type ^ GetTypeFromProgID(System::String ^ progID, System::String ^ server);
public static Type? GetTypeFromProgID (string progID, string? server);
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static Type? GetTypeFromProgID (string progID, string? server);
[System.Security.SecurityCritical]
public static Type GetTypeFromProgID (string progID, string server);
public static Type GetTypeFromProgID (string progID, string server);
static member GetTypeFromProgID : string * string -> Type
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member GetTypeFromProgID : string * string -> Type
[<System.Security.SecurityCritical>]
static member GetTypeFromProgID : string * string -> Type
Public Shared Function GetTypeFromProgID (progID As String, server As String) As Type
パラメーター
- progID
- String
取得する型の ProgID。
- server
- String
型の読み込み元のサーバー。 サーバー名が null
の場合、このメソッドは自動的にローカル マシンの名前を使用します。
戻り値
progID
がレジストリの有効なエントリで、型がそれに関連付けられている場合は、指定したプログラム ID (progID) に関連付けられている型。それ以外の場合は null
。
- 属性
例外
prodID
が null
です。
例
次の例では、ProgID とサーバー名を渡して型を取得します。 次に、ProgID に関連する ClassID を表示します。 ProgID またはサーバー名が無効な場合は、例外をスローします。
using namespace System;
int main()
{
try
{
// Use the ProgID localhost\HKEY_CLASSES_ROOT\DirControl::DirList.1.
String^ theProgramID = "DirControl.DirList.1";
// Use the server name localhost.
String^ theServer = "localhost";
// Make a call to the method to get the type information for the given ProgID.
Type^ myType = Type::GetTypeFromProgID( theProgramID, theServer );
if ( myType == nullptr )
{
throw gcnew Exception( "Invalid ProgID or Server." );
}
Console::WriteLine( "GUID for ProgID DirControl.DirList.1 is {0}.", myType->GUID );
}
catch ( Exception^ e )
{
Console::WriteLine( "An exception occurred." );
Console::WriteLine( "Source: {0}", e->Source );
Console::WriteLine( "Message: {0}", e->Message );
}
}
using System;
class MainApp
{
public static void Main()
{
try
{
// Use the ProgID localhost\HKEY_CLASSES_ROOT\DirControl.DirList.1.
string theProgramID ="DirControl.DirList.1";
// Use the server name localhost.
string theServer="localhost";
// Make a call to the method to get the type information for the given ProgID.
Type myType =Type.GetTypeFromProgID(theProgramID,theServer);
if(myType==null)
{
throw new Exception("Invalid ProgID or Server.");
}
Console.WriteLine("GUID for ProgID DirControl.DirList.1 is {0}.", myType.GUID);
}
catch(Exception e)
{
Console.WriteLine("An exception occurred.");
Console.WriteLine("Source: {0}" , e.Source);
Console.WriteLine("Message: {0}" , e.Message);
}
}
}
Class MainApp
Public Shared Sub Main()
Try
' Use ProgID localhost\HKEY_CLASSES_ROOT\DirControl.DirList.1.
Dim theProgramID As String = "DirControl.DirList.1"
' Use Server name localhost.
Dim theServer As String = "localhost"
' Make a call to the method to get the type information for the given ProgID.
Dim myType As Type = Type.GetTypeFromProgID(theProgramID, theServer)
If myType Is Nothing Then
Throw New Exception("Invalid ProgID or server.")
End If
Console.WriteLine("GUID for ProgID DirControl.DirList.1 is {0}.", myType.GUID.ToString())
Catch e As Exception
Console.WriteLine("An exception occurred.")
Console.WriteLine("Source: {0}.", e.Source.ToString())
Console.WriteLine("Message: {0}.", e.Message.ToString())
End Try
End Sub
End Class
注釈
このメソッドは、COM をサポートするために用意されています。 プログラム id は、名前空間の概念によって置き換えられているため、Microsoft .NET Framework では使用されません。
こちらもご覧ください
適用対象
GetTypeFromProgID(String, String, Boolean)
型の読み込み中にエラーが発生した場合に例外をスローするかどうかを指定して、指定したサーバーの指定したプログラム ID (ProgID) に関連付けられた型を取得します。
public:
static Type ^ GetTypeFromProgID(System::String ^ progID, System::String ^ server, bool throwOnError);
public static Type? GetTypeFromProgID (string progID, string? server, bool throwOnError);
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static Type? GetTypeFromProgID (string progID, string? server, bool throwOnError);
[System.Security.SecurityCritical]
public static Type GetTypeFromProgID (string progID, string server, bool throwOnError);
public static Type GetTypeFromProgID (string progID, string server, bool throwOnError);
static member GetTypeFromProgID : string * string * bool -> Type
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member GetTypeFromProgID : string * string * bool -> Type
[<System.Security.SecurityCritical>]
static member GetTypeFromProgID : string * string * bool -> Type
Public Shared Function GetTypeFromProgID (progID As String, server As String, throwOnError As Boolean) As Type
パラメーター
- server
- String
型の読み込み元のサーバー。 サーバー名が null
の場合、このメソッドは自動的にローカル マシンの名前を使用します。
戻り値
progID
がレジストリの有効なエントリで、型がそれに関連付けられている場合は、指定したプログラム ID (progID) に関連付けられている型。それ以外の場合は null
。
- 属性
例外
progID
が null
です。
指定された progID が登録されていません。
例
次の例では、ProgID とサーバー名を渡して型を取得します。 次に、progid に関連する ClassID が表示されます。 ProgID またはサーバー名が無効である場合に例外をスローするかどうかを指定します。
using namespace System;
int main()
{
try
{
// Use server localhost.
String^ theServer = "localhost";
// Use ProgID HKEY_CLASSES_ROOT\DirControl.DirList.1.
String^ myString1 = "DirControl.DirList.1";
// Use a wrong ProgID WrongProgID.
String^ myString2 = "WrongProgID";
// Make a call to the method to get the type information for the given ProgID.
Type^ myType1 = Type::GetTypeFromProgID( myString1, theServer, true );
Console::WriteLine( "GUID for ProgID DirControl.DirList.1 is {0}.", myType1->GUID );
// Throw an exception because the ProgID is invalid and the throwOnError
// parameter is set to True.
Type^ myType2 = Type::GetTypeFromProgID( myString2, theServer, true );
}
catch ( Exception^ e )
{
Console::WriteLine( "An exception occurred. The ProgID is wrong." );
Console::WriteLine( "Source: {0}", e->Source );
Console::WriteLine( "Message: {0}", e->Message );
}
}
using System;
class MainApp
{
public static void Main()
{
try
{
// Use server localhost.
string theServer="localhost";
// Use ProgID HKEY_CLASSES_ROOT\DirControl.DirList.1.
string myString1 ="DirControl.DirList.1";
// Use a wrong ProgID WrongProgID.
string myString2 ="WrongProgID";
// Make a call to the method to get the type information for the given ProgID.
Type myType1 =Type.GetTypeFromProgID(myString1,theServer,true);
Console.WriteLine("GUID for ProgID DirControl.DirList.1 is {0}.", myType1.GUID);
// Throw an exception because the ProgID is invalid and the throwOnError
// parameter is set to True.
Type myType2 =Type.GetTypeFromProgID(myString2, theServer, true);
}
catch(Exception e)
{
Console.WriteLine("An exception occurred. The ProgID is wrong.");
Console.WriteLine("Source: {0}" , e.Source);
Console.WriteLine("Message: {0}" , e.Message);
}
}
}
Class MainApp
Public Shared Sub Main()
Try
' Use Server localhost.
Dim theServer As String = "localhost"
' Use ProgID HKEY_CLASSES_ROOT\DirControl.DirList.1.
Dim myString1 As String = "DirControl.DirList.1"
' Use a wrong ProgID WrongProgID.
Dim myString2 As String = "WrongProgID"
' Make a call to the method to get the type information for the given ProgID.
Dim myType1 As Type = Type.GetTypeFromProgID(myString1, theServer, True)
Console.WriteLine("GUID for ProgID DirControl.DirList.1 is {0}.", myType1.GUID.ToString())
' Throw an exception because the ProgID is invalid and the throwOnError
' parameter is set to True.
Dim myType2 As Type = Type.GetTypeFromProgID(myString2, theServer, True)
Catch e As Exception
Console.WriteLine("An exception occurred. The ProgID is wrong.")
Console.WriteLine("Source: {0}", e.Source.ToString())
Console.WriteLine("Message: {0}", e.Message.ToString())
End Try
End Sub
End Class
注釈
このメソッドは、COM をサポートするために用意されています。 プログラム id は、名前空間の概念によって置き換えられているため、Microsoft .NET Framework では使用されません。