Wow6432Node
implies WOW64 virtualization. A 64-bit process can open a 32-bit virtualized key directly:
RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Wow6432Node\\Idontexist", 0, KEY_READ, &hKey);
If you need the same code to run in both 32-bit and 64-bit and both access the Wow6432Node
key, then use IsWow64Process()
in the 32-bit code to detect WOW64 and then adust the code accordingly, eg:
#ifdef _WIN64
RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Wow6432Node\\Idontexist", 0, KEY_READ, &hKey);
#else
BOOL bIsWow64 = FALSE;
IsWow64Process(GetCurrentProcess(), &bIsWow64);
DWORD Wow64Flags = (bIsWow64) ? KEY_WOW64_32KEY : 0;
RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Idontexist", 0, KEY_READ | Wow64Flags, &hKey);
#endif
However, you really shouldn't be accessing Wow6432Node
directly. KEY_WOW64_32KEY
should be working correctly if the target key is properly separated into 32-bit and 64-bit views:
DWORD Wow64Flags;
#ifdef _WIN64
Wow64Flags = KEY_WOW64_32KEY;
#else
BOOL bIsWow64 = FALSE;
IsWow64Process(GetCurrentProcess(), &bIsWow64);
Wow64Flags = (bIsWow64) ? KEY_WOW64_32KEY : 0;
#endif
RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Idontexist", 0, KEY_READ | Wow64Flags, &hKey);
If that is not working, than that implies that Software\\Wow6432Node\\Idontexist
should not have existed in the first place, and was probably incorrectly created by a 64-bit process that did not use KEY_WOW64_...
flags correctly.