Hi all,
Hope someone can help me as I’m tearing my hair out here!
I’m trying to call the registry to read HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductId.
The problem is that this is redirected by Windows by the registry redirector, and Xojo does not have the ability to read the 64 bit registry view natively.
I’ve tried coding this workaround by calling the dll directly but it’s not working. Can anyone help? Thankyou
Declare Function RegOpenKeyEx Lib “advapi32.dll” Alias “RegOpenKeyExA” (hKey As Integer, lpSubKey As CString, ulOptions As Integer, samDesired As Integer, ByRef phkResult As Integer) As Integer
Declare Function RegQueryValueExString Lib “advapi32.dll” Alias “RegQueryValueExA” (ByVal hKey As integer, ByVal lpValueName As CString, ByVal lpReserved As integer, lpType As integer, ByRef lpData As Cstring, lpcbData As integer) As integer
Const HKEY_LOCAL_MACHINE = &H80000002
Const KEY_QUERY_VALUE = &H1
Const REG_SZ = &H1
Const KEY_WOW64_64KEY = &H100
Const KEY_WOW64_32KEY = &H200
Const KEY_READ = &H20019
Const KEY_ALL_ACCESS = &HF003F
dim lResult As Integer
dim lHandle As Integer
dim slength as integer
dim retval as integer
dim hregkey as integer
dim i as double
dim stringbuffer as CString
lResult =RegOpenKeyEx(HKEY_LOCAL_MACHINE,“SOFTWARE\Microsoft\Windows NT\CurrentVersion”, 0,KEY_WOW64_64KEY, lHandle)
for i = 1 to 255
stringbuffer = stringbuffer + " "
next i
slength = 255
retval = RegQueryValueExString(lHandle, “ProductId”, &H0, REG_SZ, stringbuffer, slength)
stringbuffer = Left(stringbuffer, slength)
msgbox cstr(stringbuffer)