简体   繁体   English

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

[英]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. 我在用Java( 不是C#)寻找解决方案,并使用WinRegistry类。

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. 现在的问题是:java应用程序是32位的,我想从Windows 7 64位系统中读取reg键。 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!). 有了这些代码,Windows会将我的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");

I deleted the try-catch-block so you are able to focus the real problem more better ;). 我删除了try-catch-block,因此您可以更好地解决实际问题;)。

I solved this now - thanks goes to Petrucio who posted this solution in 2012: read/write to Windows Registry using Java . 我现在解决了这个问题-感谢Petrucio,他在2012年发布了该解决方案: 使用Java读取/写入Windows Registry

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. 我希望这对某人有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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