I am trying to read a registry value from VBA as follows:
...
Const HKEY_LOCAL_MACHINE = &H80000002
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & "." & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Computers and Structures, Inc.\SAP2000\18"
strValueName = "Install path"
oReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue
MsgBox (strValue)
Set oReg = Nothing
...
The result is that strValue returns "Null" instead of the corresponding value.
After many attempts, I guess the problem is that the strKeyPath string contains commas and/or dots, because if I try to access other keys that do not include these characters the code works fine.
Any idea on how to solve this, please?
...
Const HKEY_LOCAL_MACHINE = &H80000002
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & "." & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Computers and Structures, Inc.\SAP2000\18"
strValueName = "Install path"
oReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue
MsgBox (strValue)
Set oReg = Nothing
...
The result is that strValue returns "Null" instead of the corresponding value.
After many attempts, I guess the problem is that the strKeyPath string contains commas and/or dots, because if I try to access other keys that do not include these characters the code works fine.
Any idea on how to solve this, please?