本文整理汇总了VB.NET中System.Type.GetTypeFromProgID方法的典型用法代码示例。如果您正苦于以下问题:VB.NET Type.GetTypeFromProgID方法的具体用法?VB.NET Type.GetTypeFromProgID怎么用?VB.NET Type.GetTypeFromProgID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Type
的用法示例。
在下文中一共展示了Type.GetTypeFromProgID方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: MainApp
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
示例2: MainApp
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
示例3: MainApp
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