Type.GetTypeFromProgID Método

Definición

Obtiene el tipo asociado al identificador de programa (ProgID) especificado.

Sobrecargas

GetTypeFromProgID(String)

Obtiene el tipo asociado al identificador de programa (ProgID) especificado y devuelve null si se produce un error al cargar Type.

GetTypeFromProgID(String, Boolean)

Obtiene el tipo asociado al identificador de programa (ProgID) especificado; debe indicarse si se producirá una excepción en caso de que se produzca un error al cargar el tipo.

GetTypeFromProgID(String, String)

Obtiene el tipo asociado al identificador de programa (ProgID) especificado desde el servidor especificado y devuelve null si se produce un error al cargar el tipo.

GetTypeFromProgID(String, String, Boolean)

Obtiene el tipo asociado al identificador de programa (ProgID) indicado desde el servidor especificado; debe indicarse si se producirá una excepción en caso de que se produzca un error al cargar el tipo.

GetTypeFromProgID(String)

Obtiene el tipo asociado al identificador de programa (ProgID) especificado y devuelve null si se produce un error al cargar Type.

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

Parámetros

progID
String

ProgID del tipo que se va a obtener.

Devoluciones

Type

Tipo asociado al ProgID especificado si progID es una entrada de Registro válida y tiene un tipo asociado; en caso contrario, null.

Atributos

Excepciones

progID es null.

Comentarios

Este método se proporciona para la compatibilidad con COM. Los progID no se usan en microsoft .NET Framework porque se han reemplazado por el concepto de espacio de nombres.

Consulte también

Se aplica a

GetTypeFromProgID(String, Boolean)

Obtiene el tipo asociado al identificador de programa (ProgID) especificado; debe indicarse si se producirá una excepción en caso de que se produzca un error al cargar el tipo.

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

Parámetros

progID
String

ProgID del tipo que se va a obtener.

throwOnError
Boolean

true para producir cualquier excepción que se genere.

O bien false para pasar por alto cualquier excepción que se produzca.

Devoluciones

Type

Tipo asociado al identificador de programa (ProgID) especificado si progID es una entrada de Registro válida y tiene un tipo asociado; en caso contrario, null.

Atributos

Excepciones

progID es null.

El ProgID especificado no está registrado.

Ejemplos

En el ejemplo siguiente se recupera un tipo pasando un ProgID, especificando si se debe producir una excepción si el ProgID no es válido. A continuación, en el ejemplo se muestra el ClassID relacionado con progID, junto con cualquier mensaje de excepción aplicable.

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

Comentarios

Este método se proporciona para la compatibilidad con COM. Los identificadores de programa no se usan en Microsoft .NET Framework porque se han reemplazado por el concepto de espacio de nombres.

Consulte también

Se aplica a

GetTypeFromProgID(String, String)

Obtiene el tipo asociado al identificador de programa (ProgID) especificado desde el servidor especificado y devuelve null si se produce un error al cargar el tipo.

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

Parámetros

progID
String

ProgID del tipo que se va a obtener.

server
String

Servidor desde el que se va a cargar el tipo. Si el nombre de servidor es null, el resultado que el método devuelve automáticamente es el equipo local.

Devoluciones

Type

Tipo asociado al identificador de programa (ProgID) especificado si progID es una entrada de Registro válida y tiene un tipo asociado; en caso contrario, null.

Atributos

Excepciones

prodID es null.

Ejemplos

En el ejemplo siguiente se recupera un tipo pasando un ProgID y un nombre de servidor. A continuación, en el ejemplo se muestra el ClassID relacionado con el ProgID o se produce una excepción si el ProgID o el nombre del servidor no son válidos.

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

Comentarios

Este método se proporciona para la compatibilidad con COM. Los identificadores de programa no se usan en Microsoft .NET Framework porque se han reemplazado por el concepto de espacio de nombres.

Consulte también

Se aplica a

GetTypeFromProgID(String, String, Boolean)

Obtiene el tipo asociado al identificador de programa (ProgID) indicado desde el servidor especificado; debe indicarse si se producirá una excepción en caso de que se produzca un error al cargar el tipo.

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

Parámetros

progID
String

Identificador de programa (ProgID) del Type que se va a obtener.

server
String

Servidor desde el que se va a cargar el tipo. Si el nombre de servidor es null, el resultado que el método devuelve automáticamente es el equipo local.

throwOnError
Boolean

true para producir cualquier excepción que se genere.

O bien false para pasar por alto cualquier excepción que se produzca.

Devoluciones

Type

Tipo asociado al identificador de programa (ProgID) especificado si progID es una entrada de Registro válida y tiene un tipo asociado; en caso contrario, null.

Atributos

Excepciones

progID es null.

El ProgID especificado no está registrado.

Ejemplos

En el ejemplo siguiente se recupera un tipo pasando un ProgID y un nombre de servidor. A continuación, en el ejemplo se muestra el ClassID relacionado con progID, especificando si se debe producir una excepción si el ProgID o el nombre del servidor no son válidos.

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

Comentarios

Este método se proporciona para la compatibilidad con COM. Los identificadores de programa no se usan en Microsoft .NET Framework porque se han reemplazado por el concepto de espacio de nombres.

Consulte también

Se aplica a