' Collection of code snippets by Arne Vajhøj 
' (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
Option Explicit

Const HKEY_CLASSES_ROOT     = &H80000000
Const HKEY_CURRENT_USER     = &H80000001
Const HKEY_LOCAL_MACHINE    = &H80000002
Const HKEY_USERS            = &H80000003
Const HKEY_CURRENT_CONFIG   = &H80000005

Sub Process(ByVal objRegistry, ByVal HKEYConstant, ByVal strHKEYConstant, ByVal strKeyPrefix, ByVal dictProgId, ByRef num)
    Dim key, arrKeys
    Dim strKeyPath, strValue, uValue
    objRegistry.enumKey HKEYConstant, strKeyPrefix, arrKeys
    For Each key In arrKeys
        strKeyPath = strKeyPrefix & "\" & key
        If objRegistry.GetDWordValue(HKEYConstant, strKeyPath, "OLEDB_SERVICES", uValue) = 0 Or objRegistry.GetDWordValue(HKEYConstant, strKeyPath & "\OLEDB_SERVICES", "", uValue) = 0 Then
            objRegistry.GetStringValue HKEYConstant, strKeyPath & "\ProgID", "", strValue
            If Not dictProgId.Exists(strValue) Then
                dictProgId.Add strValue, strValue
                objRegistry.GetStringValue HKEYConstant, strKeyPath, "", strValue
                WScript.Echo  CStr(num) & ") " & strValue
                WScript.Echo "  Key: \\" & strHKEYConstant & "\" & strKeyPrefix & "\" & key
                objRegistry.GetStringValue HKEYConstant, strKeyPath & "\OLE DB Provider", "", strValue
                WScript.Echo "  OLE DB Provider: " & strValue
                objRegistry.GetStringValue HKEYConstant, strKeyPath & "\ProgID", "", strValue
                WScript.Echo "  ProgID: " & strValue
                objRegistry.GetStringValue HKEYConstant, strKeyPath & "\VersionIndependentProgID", "", strValue
                WScript.Echo "  VersionIndependentProgID: " & strValue
                num = num + 1
            End If
        End If
    Next
End Sub

Dim objRegistry
Dim num
Dim dictProgId

Set objRegistry = GetObject("winmgmts:\\.\root\default:StdRegProv")
num = 1
Set dictProgId = CreateObject("Scripting.Dictionary")

Process objRegistry, HKEY_CLASSES_ROOT, "HKEY_CLASSES_ROOT", "CLSID", dictProgId, num
Process objRegistry, HKEY_LOCAL_MACHINE, "HKEY_LOCAL_MACHINE", "SOFTWARE\Classes\CLSID", dictProgId, num
Process objRegistry, HKEY_LOCAL_MACHINE, "HKEY_LOCAL_MACHINE", "SOFTWARE\Classes\Wow6432Node\CLSID", dictProgId, num
