Type.GetTypeFromProgID Metoda
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Získá typ přidružený k zadanému identifikátoru programu (ProgID).
Přetížení
GetTypeFromProgID(String) |
Získá typ přidružený k zadanému identifikátoru programu (ProgID), který vrátí hodnotu null, pokud při načítání dojde k Type chybě. |
GetTypeFromProgID(String, Boolean) |
Získá typ přidružený k zadanému identifikátoru programu (ProgID) určující, jestli se má vyvolat výjimka, pokud při načítání typu dojde k chybě. |
GetTypeFromProgID(String, String) |
Získá typ přidružený k zadanému identifikátoru programu (progID) ze zadaného serveru a vrátí hodnotu null, pokud při načítání typu dojde k chybě. |
GetTypeFromProgID(String, String, Boolean) |
Získá typ přidružený k zadanému identifikátoru programu (progID) ze zadaného serveru a určí, jestli se má vyvolat výjimka, pokud při načítání typu dojde k chybě. |
GetTypeFromProgID(String)
Získá typ přidružený k zadanému identifikátoru programu (ProgID), který vrátí hodnotu null, pokud při načítání dojde k Type chybě.
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
Parametry
- progID
- String
ProgID typu, který se má získat.
Návraty
Typ přidružený k zadanému identifikátoru ProgID, pokud je platná položka v registru a je k ní přidružený typ. V opačném případě progID
null
hodnota .
- Atributy
Výjimky
progID
je null
.
Poznámky
Tato metoda je k dispozici za účelem podpory modelu COM. Identifikátory PROGID se v edici Microsoftu .NET Framework protože jsou nahnány konceptem oboru názvů.
Viz také
Platí pro
GetTypeFromProgID(String, Boolean)
Získá typ přidružený k zadanému identifikátoru programu (ProgID) určující, jestli se má vyvolat výjimka, pokud při načítání typu dojde k chybě.
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
Parametry
- progID
- String
ProgID typu, který se má získat.
- throwOnError
- Boolean
true
k vyvolání jakékoli výjimky, ke které dojde.
-nebo-
false
a ignorujte všechny výjimky, ke které dojde.
Návraty
Typ přidružený k zadanému identifikátoru programu (ProgID), pokud je platná položka v registru a je k ní přidružený progID
typ, jinak null
.
- Atributy
Výjimky
progID
je null
.
Zadané ProgID není zaregistrované.
Příklady
Následující příklad načte typ předáním identifikátoru ProgID a určí, jestli se má vyvolat výjimka, pokud je Id progID neplatné. V příkladu se pak zobrazí ID třídy související s ProgID spolu s příslušnou zprávou o výjimce.
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
Poznámky
Tato metoda je k dispozici za účelem podpory modelu COM. ID programů se ve službě Microsoft .NET Framework, protože jsou nahnána konceptem oboru názvů.
Viz také
Platí pro
GetTypeFromProgID(String, String)
Získá typ přidružený k zadanému identifikátoru programu (progID) ze zadaného serveru a vrátí hodnotu null, pokud při načítání typu dojde k chybě.
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
Parametry
- progID
- String
ProgID typu, který se má získat.
- server
- String
Server, ze kterého chcete typ načíst. Pokud je název serveru null
, tato metoda se automaticky vrátí na místní počítač.
Návraty
Typ přidružený k zadanému identifikátoru programu (progID), pokud je platná položka v registru a je k ní přidružený progID
typ, jinak null
.
- Atributy
Výjimky
prodID
je null
.
Příklady
Následující příklad načte typ předáním ProgID a názvu serveru. V příkladu se pak zobrazí CLASSID související s ProgID nebo vyvolá výjimku, pokud JegID nebo název serveru je neplatný.
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
Poznámky
Tato metoda je k dispozici za účelem podpory modelu COM. ID programů se ve službě Microsoft .NET Framework, protože jsou nahnána konceptem oboru názvů.
Viz také
Platí pro
GetTypeFromProgID(String, String, Boolean)
Získá typ přidružený k zadanému identifikátoru programu (progID) ze zadaného serveru a určí, jestli se má vyvolat výjimka, pokud při načítání typu dojde k chybě.
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
Parametry
- server
- String
Server, ze kterého chcete typ načíst. Pokud je název serveru null
, tato metoda se automaticky vrátí na místní počítač.
- throwOnError
- Boolean
true
k vyvolání jakékoli výjimky, ke které dojde.
-nebo-
false
a ignorujte všechny výjimky, ke které dojde.
Návraty
Typ přidružený k zadanému identifikátoru programu (progID), pokud je platná položka v registru a je k ní přidružený progID
typ, jinak null
.
- Atributy
Výjimky
progID
je null
.
Zadané progID není zaregistrované.
Příklady
Následující příklad načte typ předáním ProgID a názvu serveru. Příklad pak zobrazí ID třídy související s ProgID a určí, jestli se má vyvolat výjimka, pokud je Id skupiny nebo název serveru neplatné.
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
Poznámky
Tato metoda je k dispozici za účelem podpory modelu COM. ID programů se ve službě Microsoft .NET Framework, protože jsou nahnána konceptem oboru názvů.