Hi Guys,
Can someone help me to get the variable from a declared Const into my proc. The "hKey" does not pick up the Const value in the line "oReg.EnumKey hKey, rPath, arrSubKeys"
This code runs fine when I hard code the value in the proc and also works ok when I use the value "Software\Microsoft" in cell C4. I want this to be more interactive by entering "HKCU" in cell C3 but this is a stumbling block as it doesn't pick up the value "&H80000001".
Is there an orthodox way to achieve this.
Thanks.
Can someone help me to get the variable from a declared Const into my proc. The "hKey" does not pick up the Const value in the line "oReg.EnumKey hKey, rPath, arrSubKeys"
This code runs fine when I hard code the value in the proc and also works ok when I use the value "Software\Microsoft" in cell C4. I want this to be more interactive by entering "HKCU" in cell C3 but this is a stumbling block as it doesn't pick up the value "&H80000001".
Is there an orthodox way to achieve this.
Thanks.
Code:
Const HKCR = &H80000000
Const HKCU = &H80000001
Const HKLM = &H80000002
Sub RegQ()
Dim oReg As Object
Dim strComputer As String
Dim hKey As String
Dim rPath As String
Dim arrSubKeys()
Dim strAsk
r = Selection.Row: c = Selection.Column
strComputer = "."
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")
hKey = Selection.Offset(-1, 0).Value ' Say: HKCU in C3
rPath = Selection.Value & "\" ' Say: Software\Microsoft in C4
oReg.EnumKey hKey, rPath, arrSubKeys
r = r + 1
For Each strAsk In arrSubKeys
Cells(r, c) = strAsk
Cells(r, c - 1) = rPath & strAsk
r = r + 1
Next
Set oReg = Nothing
End Sub