Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing 64-bit Registry in 32-bit application

Tags:

java

registry

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 ;).

like image 425
Nighty42 Avatar asked Jul 24 '13 14:07

Nighty42


1 Answers

I solved this now - thanks goes to Petrucio who posted this solution in 2012: read/write to Windows Registry using Java.

E.g. - 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.

like image 119
Nighty42 Avatar answered Sep 27 '22 00:09

Nighty42