Hi,
I found several scripts how to Read/Write the windows Registry.
But I cannot figure out how to Read the (Default) key.
I'm using this code, but gives error on the (default) key.
Anybody has any ideas how to get this working?
Other keys with "real" names work perfectly.
I created a code from the example given on this website:
http://www.jpsoftwaretech.com/vba/grab-registry-settings-through-vba-using-wmi/
<code>
'===== GetStdRegProv, which calls the WMI service and returns the appropriate object. =====
Function GetStdRegProv() As Object
' http://msdn.microsoft.com/en-us/library/aa394600(VS.85).aspxDim strComputer As String
strComputer = "."
Set GetStdRegProv = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\default:StdRegProv")
End Function
' ===== READ REG VALUES =====
Function CDT_REGread_UserData()
Dim RegistryKey As String
Dim strValue As String
Dim objReg As Object
Set objReg = GetStdRegProv ' <--- Get WMI Object
RegistryKey = "Software\Microsoft\Internet Explorer"
objReg.GetStringValue &H80000001, RegistryKey, "(default)", strValue
myVK = strValue
Debug.Print "VK: " & myVK
End Function
</code>
I found several scripts how to Read/Write the windows Registry.
But I cannot figure out how to Read the (Default) key.
I'm using this code, but gives error on the (default) key.
Anybody has any ideas how to get this working?
Other keys with "real" names work perfectly.
I created a code from the example given on this website:
http://www.jpsoftwaretech.com/vba/grab-registry-settings-through-vba-using-wmi/
<code>
'===== GetStdRegProv, which calls the WMI service and returns the appropriate object. =====
Function GetStdRegProv() As Object
' http://msdn.microsoft.com/en-us/library/aa394600(VS.85).aspxDim strComputer As String
strComputer = "."
Set GetStdRegProv = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\default:StdRegProv")
End Function
' ===== READ REG VALUES =====
Function CDT_REGread_UserData()
Dim RegistryKey As String
Dim strValue As String
Dim objReg As Object
Set objReg = GetStdRegProv ' <--- Get WMI Object
RegistryKey = "Software\Microsoft\Internet Explorer"
objReg.GetStringValue &H80000001, RegistryKey, "(default)", strValue
myVK = strValue
Debug.Print "VK: " & myVK
End Function
</code>