在32位应用程序中访问64位注册表

Nig*_*y42 4 java registry

请不要将此问题标记为重复!

我在java中搜索解决方案 - 而不是C# - 并使用WinRegistry类.

我写了一个可以读出注册表项的程序.现在问题:java应用程序是32位,我想从Windows 7 64位系统读取reg键.使用此代码窗口将我的32位程序重定向到64位注册表的32位部分(比较真实路径与代码中的注释 - 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");
Run Code Online (Sandbox Code Playgroud)

我删除了try-catch-block,这样你就能更好地关注真正的问题;).

Nig*_*y42 6

我现在解决了这个问题 - 感谢Petrucio在2012年发布了这个解决方案:使用Java读取/写入Windows注册表.

例如 - 读操作:

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(); 
}
Run Code Online (Sandbox Code Playgroud)

我希望这对某人有用.