Created
April 8, 2014 16:35
-
-
Save evancummings/10152860 to your computer and use it in GitHub Desktop.
List All COM Components on a Local Machine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'http://www.devx.com/vb2themax/Tip/18726 | |
' 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment