0

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

amoljdv06
  • 2,646
  • 1
  • 13
  • 18

1 Answers1

1

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.

Community
  • 1
  • 1
selbie
  • 100,020
  • 15
  • 103
  • 173
  • Yes I can run the 32-bit java.exe on the 64-bit system and its work propery. Registry entry saved into WOW6432Node as well. Its may possible that the implementation attempting to pass the KEY_WOW_flag so how do enable KEY_WOW_flag before requesting for key. Is there any Java api or such Java approach – amoljdv06 Jan 05 '17 at 05:48
  • If your code detects it's running on 64-bit java then it requests to read `HKEY_LOCAL_MACHINE\Software\Wow6432Node\MyApp` else if on 32-bit java the request is made `HKEY_LOCAL_MACHINE\Software\MyApp`. Won't that work for you? – selbie Jan 05 '17 at 06:35
  • Issue got solved , in last release of my application, I had build it with 32 bit installer but accidentally i had used JRE 64 bit instead of JRE 32 bit, As a result issue got raised. Today I have rebuild it with JRE 32 bit, now it works as expected Thanks @selbie for your afford for finding info, it helped me to reach route cause of issue. – amoljdv06 Jan 11 '17 at 06:58