GetRegistryValueWow64 method


When you are working on 64-bit Windows and you read a registry key from a 32-bit application, it is redirected to the "SysWOW64" folder, where the 32-bit registry is. On the other hand, if you read the same registry key from a 64-bit application, the key is read from the 64-bit registry (in the "System32" folder) and its value can be different. In order to read a 64-bit registry key from a 32-bit application, or a 32-bit registry key from a 64-bit application, use the GetRegistryValueWow64 method as explained below.

Prototype

GetRegistryValueWow64 Proto hKey:HKEY, lpszSubKey:LPSTR, lpszValueName:LPSTR, lpszValue:LPSTR

Syntax

Invoke GetRegistryValueWow64, hKey, lpszSubKey, lpszValueName, lpszValue

Function

Accesses a 64-bit registry key when called from 32-bit applications, or a 32-bit registry key when called from 64-bit applications..

Parameters

hKey

Handle to one of the following predefined keys:

ecClassesRoot
ecCurrentUser
ecLocalMachine
ecUsers
ecPerformanceData
ecCurrentConfig
ecDynData

lpszSubKey

Pointer to the effective address of a null-terminated string that names the path of the subkey containing the named value whose value is to be retrieved.

lpszValueName

Pointer to the effective address of a null-terminated string that names the named value whose value is to be retrieved.

lpszValue

Pointer to the effective address of a null-terminated string to receive the retrieved value.

Return value

Eax/Rax returns TRUE if successful, or FALSE if not.


REMARKS: The lpszValue parameter points to a null-terminated string to receive the retrieved data. You can fill this parameter with the desired default value before calling the method, as it will return the same value if the specified named value is not found.

REMARKS: The GetRegistryValueWow64 method expects lpszSubKey and lpszValueName to be Unicode strings, and fills lpszValue with a Unicode value if the application is running as Unicode. Otherwise, it expects lpszSubKey and lpszValueName to be ANSI strings, and fills lpszValue with an ANSI value (see the IsAppUnicode method). You can call GetRegistryValueWow64A to get ANSI values in Unicode applications, or GetRegistryValueWow64W to get Unicode values in ANSI applications.

IMPORTANT: The string pointed by lpszValue must be able to allocate up to MAX_PATH characters.