Registry using RegQueryValueEx with REG_DWORD problem


G

Guest

I dont understand why RegQueryValueEx always returns succesully but gives
back 0 when using REG_DWORD enven though the actual registry value is >0 ?

example:

Private Const ERROR_NONE = 0
Private Const REG_DWORD As Long = 4
Private Const STANDARD_RIGHTS_READ = &H20000
Private Const KEY_QUERY_VALUE As Long = &H1
Private Const KEY_READ = (STANDARD_RIGHTS_READ Or KEY_QUERY_VALUE)
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
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias
"RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, _
ByVal lpReserved As Long, lpType As Long, ByVal lpData As Any, lpcbData
As Long) As Long

Private Sub Button1_Click()

Dim result&, hKey&, lngValue&

result = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
"SOFTWARE\Microsoft\Office\11.0\Common\General", 0, KEY_READ, hKey)

If result = ERROR_NONE Then
result = RegQueryValueEx(hKey, "InstalledOnWin2K", 0, REG_DWORD,
lngValue, 4)

If result = ERROR_NONE Then MsgBox Hex(lngValue)
End If

End Sub
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top