I have an 32-bit application that reads the registry and looks for a value in HKEY_LOCAL_MACHINE\Software\MyApp\ but when running on 64-bit versions of windows, the value is under HKEY_LOCAL_MACHINE\Software\Wow6432Node\MyApp. But my application still looks for a value in HKEY_LOCAL_MACHINE\Software\MyApp\
I am using com.zerog.ia.api.pub.SimpleRegistryManager api for registry manipulation This class used to access the Win32 system Registry.
In ref of MSDN, The KEY_WOW64_32KEY flag is uses to access a 32-bit key from either a 32-bit or 64-bit application. https://msdn.microsoft.com/en-us/library/windows/desktop/aa384129(v=vs.85).aspx
So is any way to enable or disable KEY_WOW64_32KEY flag using Java api
I suspect that your program will just work without modification if it's running under the 32-bit version of java.exe. Can you run the 32-bit java.exe on the 64-bit system and see if it works?
My advice would be to reference this link on how to detect if your program is running under 32-bit or 64-bit VM. Then change the code to reference the Wow64 registry key path when running on 64-bit.
I'm not familiar with the SimpleRegistryManager class that you speak of, but it's also possible that the implementation attempting to pass the KEY_WOW_ flag based on VM type and conflicting with what you really want it to do.
This isn't an uncommon bug for developers on Windows. (Especially when interoping with various 32-bit and 64-bit apps on 64-bit windows.) Some folks take a lazy approach. When they attempt to read the registry key, if the the key doesn't exist in HKLM\Software\MyApp
, then the code falls back to attempting to read the key from HKLM\Software\Wow6432Node\MyApp
.