Re: VB6 - getting contents of registry entry [modified]
-
Hello, I have been trying to get the contents of a registry entry. I tried the following:
'http://www.andreavb.com/tip080001.html
Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, _
ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long _
) As Long'http://www.windowsdevcenter.com/pub/a/windows/2004/07/27/VB\_Registry\_Values.html
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" ( _
ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, _
lpType As Long, lpData As Any, lpcbData As Long) As LongPrivate Sub Form_Load()
RegOpenKeyEx HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion", _
0&, KEY_READ, hKey
RegQueryValueEx hKey, "CommonFilesDir", 0, 0, sValue, iTemp
End SubAfter the RegOpenKeyEx is executed, hKey has a value of 0. Something doesn't seem right here. Can anyone help?
Regards, Mike
modified on Tuesday, January 22, 2008 9:37:31 AM
-
Hello, I have been trying to get the contents of a registry entry. I tried the following:
'http://www.andreavb.com/tip080001.html
Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, _
ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long _
) As Long'http://www.windowsdevcenter.com/pub/a/windows/2004/07/27/VB\_Registry\_Values.html
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" ( _
ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, _
lpType As Long, lpData As Any, lpcbData As Long) As LongPrivate Sub Form_Load()
RegOpenKeyEx HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion", _
0&, KEY_READ, hKey
RegQueryValueEx hKey, "CommonFilesDir", 0, 0, sValue, iTemp
End SubAfter the RegOpenKeyEx is executed, hKey has a value of 0. Something doesn't seem right here. Can anyone help?
Regards, Mike
modified on Tuesday, January 22, 2008 9:37:31 AM
I changed Form_Load as shown below:
Private Sub Form_Load()
HKEY_LOCAL_MACHINE = &H80000002
KEY_READ = &H20019
RegOpenKeyEx HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion", _
0&, KEY_READ, hKey
RegQueryValueEx hKey, "CommonFilesDir", 0, 0, sValue, iTemp
End SubNow, I'm getting a non-zero value for hKey, but still I'm getting nothing for sValue. Anyone have any ideas?
Regards, Mike
modified on Tuesday, January 22, 2008 10:49:23 AM