Type.GetTypeFromProgID 메서드

정의

지정된 ProgID(프로그램 식별자)와 연관된 형식을 가져옵니다.

오버로드

GetTypeFromProgID(String)

지정된 ProgID(프로그램 식별자)와 연관된 형식을 가져오고 Type을 로드하는 동안 오류가 발생하면 null을 반환합니다.

GetTypeFromProgID(String, Boolean)

지정된 ProgID(프로그램 식별자)와 연관된 형식을 가져오고 형식을 로드하는 동안 오류가 발생하면 예외를 throw할지를 지정합니다.

GetTypeFromProgID(String, String)

지정된 ProgID(프로그램 식별자)와 연관된 형식을 지정된 서버에서 가져오고, 형식을 로드하는 동안 오류가 발생하면 null을 반환합니다.

GetTypeFromProgID(String, String, Boolean)

지정된 ProgID(프로그램 식별자)와 연관된 형식을 지정된 서버에서 가져오고, 형식을 로드하는 동안 오류가 발생하면 예외를 throw할지를 지정합니다.

GetTypeFromProgID(String)

지정된 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입니다.

반환

Type

progID가 유효한 레지스트리 항목이고 형식과 관련되어 있으면 지정된 ProgID와 관련된 형식을 반환하고, 그렇지 않으면 null을 반환합니다.

특성

예외

progID이(가) null인 경우

설명

이 메서드는 COM 지원을 위해 제공됩니다. ProgID는 네임스페이스 개념으로 대체되었으므로 Microsoft .NET Framework 사용되지 않습니다.

추가 정보

적용 대상

GetTypeFromProgID(String, Boolean)

지정된 ProgID(프로그램 식별자)와 연관된 형식을 가져오고 형식을 로드하는 동안 오류가 발생하면 예외를 throw할지를 지정합니다.

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입니다.

throwOnError
Boolean

발생하는 예외를 모두 throw하려면true 입니다.

또는 false는 발생하는 예외를 모두 무시합니다.

반환

Type

progID가 유효한 레지스트리 항목이고 형식과 관련되어 있으면 지정된 ProgID(프로그램 식별자)와 관련된 형식을 반환하고, 그렇지 않으면 null을 반환합니다.

특성

예외

progID이(가) null인 경우

지정된 ProgID가 등록되어 있지 않습니다.

예제

다음 예제에서는 ProgID가 잘못된 경우 예외를 throw할지 여부를 지정하여 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)

지정된 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이면 이 메서드는 자동으로 로컬 컴퓨터로 전환됩니다.

반환

Type

progID가 유효한 레지스트리 항목이고 형식과 관련되어 있으면 지정된 ProgID(프로그램 식별자)와 관련된 형식을 반환하고, 그렇지 않으면 null을 반환합니다.

특성

예외

prodID이(가) null인 경우

예제

다음 예제에서는 ProgID 및 서버 이름을 전달하여 형식을 검색합니다. 그런 다음 ProgID와 관련된 ClassID를 표시하거나 ProgID 또는 서버 이름이 잘못된 경우 예외를 throw합니다.

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)

지정된 ProgID(프로그램 식별자)와 연관된 형식을 지정된 서버에서 가져오고, 형식을 로드하는 동안 오류가 발생하면 예외를 throw할지를 지정합니다.

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

매개 변수

progID
String

가져올 Type의 ProgID입니다.

server
String

형식을 로드할 서버입니다. 서버 이름이 null이면 이 메서드는 자동으로 로컬 컴퓨터로 전환됩니다.

throwOnError
Boolean

발생하는 예외를 모두 throw하려면 true입니다.

또는 false는 발생하는 예외를 모두 무시합니다.

반환

Type

progID가 유효한 레지스트리 항목이고 형식과 관련되어 있으면 지정된 ProgID(프로그램 식별자)와 관련된 형식을 반환하고, 그렇지 않으면 null을 반환합니다.

특성

예외

progID이(가) null인 경우

지정된 ProgID가 등록되어 있지 않습니다.

예제

다음 예제에서는 ProgID 및 서버 이름을 전달하여 형식을 검색합니다. 그런 다음 ProgID 또는 서버 이름이 잘못된 경우 예외를 throw할지 여부를 지정하여 ProgID와 관련된 ClassID를 표시합니다.

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 사용되지 않습니다.

추가 정보

적용 대상