Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: VB.NET
Expertise: Intermediate
Mar 16, 2002



Building the Right Environment to Support AI, Machine Learning and Deep Learning

List all COM components on local machine

The following routine parses the registry and lists all the installed COM components:

' this code assumes that you have used this Imports statement
' Imports Microsoft.Win32

' Print ProgID, CLSID, and path of all the COM components
' installed on this computer.
Sub DisplayCOMComponents()
    ' Open the HKEY_CLASSES_ROOT\CLSID key
    Dim regClsid As RegistryKey = Registry.ClassesRoot.OpenSubKey("CLSID")

    ' Iterate over all the subkeys.
    Dim clsid As String
    For Each clsid In regClsid.GetSubKeyNames
        ' Open the subkey.
        Dim regClsidKey As RegistryKey = regClsid.OpenSubKey(clsid)

        ' Get the ProgID. (This is the default value for this key.)
        Dim ProgID As String = CStr(regClsidKey.GetValue(""))
        ' Get the InProcServer32 key, which holds the DLL path.
        Dim regPath As RegistryKey = regClsidKey.OpenSubKey("InprocServer32")
        If regPath Is Nothing Then
            ' If not found, it isn't an in-process DLL server, 
            ' let's see if it's an out-of-process EXE server.
            regPath = regClsidKey.OpenSubKey("LocalServer32")
        End If
        If Not (regPath Is Nothing) Then
            ' If either key has been found, retrieve its default value.
            Dim filePath As String = CStr(regPath.GetValue(""))
            ' Display all the relevant info gathered so far.
            Console.WriteLine(ProgId & " " & clsid & " -> " & filePath)
            ' Always close registry keys.
        End If
        ' Always close registry keys.
End Sub

Francesco Balena
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date