dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


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

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


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.
            regPath.Close()
        End If
        ' Always close registry keys.
        regClsidKey.Close()
    Next
End Sub

Francesco Balena
 
Comment and Contribute

 

 

 

 

 


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

 

 

Sitemap
×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date