Access to a 64-bit registry in a 32-bit application

Do not put this question as a duplicate!

I am looking for a solution in java - not C # - and used the WinRegistry class.

I wrote a program that can read the registry key. Now the problem: the java application is 32 bits, and I want to read the reg keys from the 64-bit system of Windows 7. With this code, the windows will redirect my 32-bit program to the 32-bit section of the 64-bit registry (compare the real path with a comment in the code is Wow6432Node!).

// only access to "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run" value = WinRegistry.readString(WinRegistry.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", "Citrix Login Service"); 

I removed the try-catch block so you can better focus the real problem;).

+4
source share
1 answer

I solved it now - thanks to Petrucio, who published this solution in 2012: read / write to the Windows registry using Java .

eg. - read operation:

 try { String value = WinRegistry.readString(WinRegistry.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", "TestValue", WinRegistry.KEY_WOW64_64KEY); System.out.println(value); } catch (Exception ex) { ex.printStackTrace(); } 

I hope this is helpful to someone.

+5
source

Source: https://habr.com/ru/post/1493230/


All Articles