Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Type.GetTypeFromCLSID Method (Guid)

.NET Framework 1.1

Gets the type associated with the specified class identifier (CLSID).

[Visual Basic]
Overloads Public Shared Function GetTypeFromCLSID( _
   ByVal clsid As Guid _
) As Type
[C#]
public static Type GetTypeFromCLSID(
 Guid clsid
);
[C++]
public: static Type* GetTypeFromCLSID(
 Guid clsid
);
[JScript]
public static function GetTypeFromCLSID(
   clsid : Guid
) : Type;

Parameters

clsid
The CLSID of the type to get.

Return Value

System.__ComObject regardless of whether the CLSID is valid.

Example

[Visual Basic, C#, C++] The following example retrieves a GUID by passing the clsid parameter to the constructor of the Guid structure, and then retrieves the type associated with the specified class identifier (CLSID).

[Visual Basic] 
Imports System
Class MyGetTypeFromCLSID
    Public Shared Sub Main()
        ' Create  a GUID object by passing the clsid parameter.
        Dim myGuid1 As New Guid("1AE77DA4-1063-4ab3-BCD2-085B001EFB97")
        ' Get the type associated with the CLSID.
        Dim myType1 As Type = Type.GetTypeFromCLSID(myGuid1)
        ' Display the GUID.
        Console.WriteLine(myType1.GUID.ToString())
        ' Convert the GUID to a string.
        Console.WriteLine(myType1.ToString())
    End Sub 'Main 
End Class 'MyGetTypeFromCLSID

[C#] 
using System;
class MyGetTypeFromCLSID
{
    public static void Main()
    {
        // Create a GUID object by passing the clsid parameter.
        Guid myGuid1 = new Guid("1AE77DA4-1063-4ab3-BCD2-085B001EFB97");
        // Get the type object associated with the CLSID.
        Type myType1 = Type.GetTypeFromCLSID(myGuid1);
        // Display the GUID.
        Console.WriteLine(myType1.GUID);
        // Convert the GUID to a string.
        Console.WriteLine(myType1.ToString());                        
    }
}

[C++] 
#using <mscorlib.dll>

using namespace System;

int main() {
   // Create a GUID object by passing the clsid parameter.
   Guid myGuid1 = Guid(S"1AE77DA4-1063-4ab3-BCD2-085B001EFB97");
   // Get the type object associated with the CLSID.
   Type*  myType1 = Type::GetTypeFromCLSID(myGuid1);
   // Display the GUID.
   Console::WriteLine(__box(myType1->GUID));
   // Convert the GUID to a String*.
   Console::WriteLine(myType1);
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

Type Class | Type Members | System Namespace | Type.GetTypeFromCLSID Overload List

Show:
© 2014 Microsoft. All rights reserved.