GeorgeT
October 16th, 2001, 12:45 PM
Hi,
I need to read value from HKEY_LOCAL_MACHINE.
Same code works for HKEY_CURRENT_USER. Anybody knows whats is going on? Thanks for help.
Function call
DAAPath = GetRegEntry(HKEY_LOCAL_MACHINE, "\Software\Test", "DAA2000")
'---------------------------------------------
Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (byval hkey as Long, byval lpSubKey as string, phkResult as Long) as Long
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 Long
Declare Function RegCloseKey Lib "advapi32.dll" (byval hkey as Long) as Long
public Const ERROR_SUCCESS = 0&
public Const HKEY_CLASSES_ROOT = &H80000000
public Const HKEY_CURRENT_USER = &H80000001
public Const HKEY_LOCAL_MACHINE = &H80000002
public Const HKEY_USERS = &H80000003
public Const HKEY_PERFORMANCE_DATA = &H80000004
public Const HKEY_CURRENT_CONFIG = &H80000005
public Const HKEY_DYN_DATA = &H80000006
Function GetRegEntry(RootKey as Long, SubKeyName as string, KeyEntry as string) as string
If RegOpenKey(RootKey, SubKeyName, hkey&) = ERROR_SUCCESS then
Returned$ = Space$(255)
Success& = RegQueryValueEx(hkey&, KeyEntry, 0&, lpType&, byval Returned$, 255)
Returned$ = Trim$(Returned$)
If (Returned$ <> "") then
GetRegEntry = Left$(Returned$, len(Returned$) - 1)
End If
RegCloseKey (hkey&)
End If
End Function
I need to read value from HKEY_LOCAL_MACHINE.
Same code works for HKEY_CURRENT_USER. Anybody knows whats is going on? Thanks for help.
Function call
DAAPath = GetRegEntry(HKEY_LOCAL_MACHINE, "\Software\Test", "DAA2000")
'---------------------------------------------
Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (byval hkey as Long, byval lpSubKey as string, phkResult as Long) as Long
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 Long
Declare Function RegCloseKey Lib "advapi32.dll" (byval hkey as Long) as Long
public Const ERROR_SUCCESS = 0&
public Const HKEY_CLASSES_ROOT = &H80000000
public Const HKEY_CURRENT_USER = &H80000001
public Const HKEY_LOCAL_MACHINE = &H80000002
public Const HKEY_USERS = &H80000003
public Const HKEY_PERFORMANCE_DATA = &H80000004
public Const HKEY_CURRENT_CONFIG = &H80000005
public Const HKEY_DYN_DATA = &H80000006
Function GetRegEntry(RootKey as Long, SubKeyName as string, KeyEntry as string) as string
If RegOpenKey(RootKey, SubKeyName, hkey&) = ERROR_SUCCESS then
Returned$ = Space$(255)
Success& = RegQueryValueEx(hkey&, KeyEntry, 0&, lpType&, byval Returned$, 255)
Returned$ = Trim$(Returned$)
If (Returned$ <> "") then
GetRegEntry = Left$(Returned$, len(Returned$) - 1)
End If
RegCloseKey (hkey&)
End If
End Function