Type.GetTypeFromProgIDとは? わかりやすく解説

Type.GetTypeFromProgID メソッド (String, Boolean)

型の読み込み中にエラーが発生した場合例外スローするかどうか指定して指定したプログラム ID (ProgID) に関連付けられた型を取得します

名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Shared Function GetTypeFromProgID
 ( _
    progID As String, _
    throwOnError As Boolean _
) As Type
Dim progID As String
Dim throwOnError As Boolean
Dim returnValue As Type

returnValue = Type.GetTypeFromProgID(progID, throwOnError)
public static Type GetTypeFromProgID (
    string progID,
    bool throwOnError
)
public:
static Type^ GetTypeFromProgID (
    String^ progID, 
    bool throwOnError
)
public static Type GetTypeFromProgID (
    String progID, 
    boolean throwOnError
)
public static function GetTypeFromProgID
 (
    progID : String, 
    throwOnError : boolean
) : Type

パラメータ

progID

取得する型の ProgID。

throwOnError

発生した例外をすべてスローする場合true

または

発生した例外をすべて無視する場合false

戻り値
progIDレジストリ有効なエントリで、型がそれに関連付けられている場合は、指定したプログラム ID (ProgID) に関連付けられている型。それ以外場合null 参照 (Visual Basic では Nothing)。

例外例外
例外種類条件

ArgumentException

progIDnull 参照 (Visual Basic では Nothing) です。

COMException

指定された ProgID が登録されていません。

解説解説
使用例使用例

ProgID が無効な場合例外スローするかどうか指定して、ProgID を渡して型を取得する例を次に示します。この例では次に、ProgID に関連付けられている ClassID、および該当する例メッセージ表示します

Imports System
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 'Main 
End Class 'MainApp
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);
        }
    }
}
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 );
   }

}

.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

Type.GetTypeFromProgID メソッド (String, String, Boolean)

型の読み込み中にエラーが発生した場合例外スローするかどうか指定して指定したサーバー指定したプログラム ID (ProgID) に関連付けられた型を取得します

名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Shared Function GetTypeFromProgID
 ( _
    progID As String, _
    server As String, _
    throwOnError As Boolean _
) As Type
Dim progID As String
Dim server As String
Dim throwOnError As Boolean
Dim returnValue As Type

returnValue = Type.GetTypeFromProgID(progID, server, throwOnError)
public static Type GetTypeFromProgID (
    string progID,
    string server,
    bool throwOnError
)
public:
static Type^ GetTypeFromProgID (
    String^ progID, 
    String^ server, 
    bool throwOnError
)
public static Type GetTypeFromProgID (
    String progID, 
    String server, 
    boolean throwOnError
)
public static function GetTypeFromProgID
 (
    progID : String, 
    server : String, 
    throwOnError : boolean
) : Type

パラメータ

progID

取得する Typeプログラム ID

server

型の読み込み元のサーバーサーバー名が null 参照 (Visual Basic では Nothing) の場合、このメソッド自動的にローカル マシンの名前を使用します

throwOnError

発生した例外をすべてスローする場合true

または

発生した例外をすべて無視する場合false

戻り値
progIDレジストリ有効なエントリで、型がそれに関連付けられている場合は、指定したプログラム ID (progID) に関連付けられている Typeそれ以外場合null 参照 (Visual Basic では Nothing)。

例外例外
例外種類条件

ArgumentException

progIDnull 参照 (Visual Basic では Nothing) です。

COMException

指定された ProgId が登録されていません。

解説解説
使用例使用例

ProgID とサーバー名を渡して型を取得する例を次に示します。この例では次に、ProgID かサーバー名が無効な場合例外スローするかどうか指定して、ProgID に関連付けられている ClassID表示します

Imports System
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 'Main 
End Class 'MainApp
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);
        }
    }
}
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 );
   }

}

.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
Type クラス
Type メンバ
System 名前空間
GetProgIdForType
TypeLoadException
ReflectionPermission

Type.GetTypeFromProgID メソッド (String, String)

指定したサーバーから、指定したプログラム ID (progID) に関連付けられている型を取得し、型の読み込み中にエラーが発生した場合null返します

名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Shared Function GetTypeFromProgID
 ( _
    progID As String, _
    server As String _
) As Type
Dim progID As String
Dim server As String
Dim returnValue As Type

returnValue = Type.GetTypeFromProgID(progID, server)
public static Type GetTypeFromProgID (
    string progID,
    string server
)
public:
static Type^ GetTypeFromProgID (
    String^ progID, 
    String^ server
)
public static Type GetTypeFromProgID (
    String progID, 
    String server
)
public static function GetTypeFromProgID
 (
    progID : String, 
    server : String
) : Type

パラメータ

progID

取得する型の ProgID。

server

型の読み込み元のサーバーサーバー名が null 参照 (Visual Basic では Nothing) の場合、このメソッド自動的にローカル マシンの名前を使用します

戻り値
progIDレジストリ有効なエントリで、型がそれに関連付けられている場合は、指定したプログラム ID (ProgID) に関連付けられている型。それ以外場合null 参照 (Visual Basic では Nothing)。

例外例外
例外種類条件

ArgumentException

prodIDnull 参照 (Visual Basic では Nothing) です。

解説解説
使用例使用例

ProgID とサーバー名を渡して型を取得する例を次に示します。この例では次に、ProgID に関連付けられている ClassID表示するか、ProgID かサーバー名が無効な場合例外スローます。

Imports System
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 'Main
End Class 'MainApp
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);
        }        
    }
}
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 );
   }

}

.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

Type.GetTypeFromProgID メソッド (String)

指定したプログラム ID (ProgID) に関連付けられている型を取得しType読み込み中にエラーが発生した場合null返します

名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Shared Function GetTypeFromProgID
 ( _
    progID As String _
) As Type
Dim progID As String
Dim returnValue As Type

returnValue = Type.GetTypeFromProgID(progID)
public static Type GetTypeFromProgID (
    string progID
)
public:
static Type^ GetTypeFromProgID (
    String^ progID
)
public static Type GetTypeFromProgID (
    String progID
)
public static function GetTypeFromProgID
 (
    progID : String
) : Type

パラメータ

progID

取得する型の ProgID。

戻り値
progIDレジストリ有効なエントリで、型がそれに関連付けられている場合は、指定したクラス ProgID に関連付けられている型。それ以外場合null 参照 (Visual Basic では Nothing)。

例外例外
例外種類条件

ArgumentException

progIDnull 参照 (Visual Basic では Nothing) です。

解説解説
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

Type.GetTypeFromProgID メソッド




英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「Type.GetTypeFromProgID」の関連用語

Type.GetTypeFromProgIDのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Type.GetTypeFromProgIDのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS