简体   繁体   中英

Accessing 64-bit Registry in 32-bit application

Please do not mark this question as duplicate!

I'm searching for a solution in java - not C# - and used the WinRegistry class.

I wrote a program that can readout a registry key. Now the problem: the java application is 32bit and I want to read the reg-keys from a windows 7 64bit-system. With this code windows will redirect my 32bit program to the 32bit section of the 64bit-registry (compare the real path with the comment in the code - 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 deleted the try-catch-block so you are able to focus the real problem more better ;).

I solved this now - thanks goes to Petrucio who posted this solution in 2012: read/write to 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 that is usefully for someone.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM