使用java.util.prefs.Preferences使用Windows注册表 [英] Working with Windows registry using java.util.prefs.Preferences
本文介绍了使用java.util.prefs.Preferences使用Windows注册表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对注册表有一些疑问。
我们有
I have some questions about the registry.
We have
Preferences p = Preferences.userRoot();
如果我们执行
p.nodeExists("/HKEY_CURRENT_USER/Software/Policies/Microsoft")
它将返回true。
之后:
it will return true.
After it:
p = p.node("/HKEY_CURRENT_USER/Software/Policies");
for(String s : p.childrenNames()){
System.out.println(">" + s);
}
我们看到它有一个孩子:Windows。但
We see that it has one child: "Windows". But
p.nodeExists("/HKEY_CURRENT_USER/Software/Policies/Microsoft/Windows")
返回false。为什么?
returns false. Why?
谢谢。
更新
好的。我有一些错误。让我再试一次:为什么
Ok. I have some mistakes. Let me try again: Why does
p.nodeExists("/HKEY_CURRENT_USER/Software/Policies/Microsoft/Windows")
返回false?
推荐答案
如果你按照显示的顺序执行显示的代码行,当你到达行
If you execute the code lines shown, in the order shown, when you get to the line
p.nodeExists("/HKEY_CURRENT_USER/Software/Policies/Microsoft/Windows")
p
不再指向用户root,而是指向/ HKEY_CURRENT_USER / Software / Policies。
p
does not anymore point to the user root, but to "/HKEY_CURRENT_USER/Software/Policies".
如果您有可能遗漏您的第三个代码示例:
Btw you have a probable omission in your third code sample:
p = p.node("/HKEY_CURRENT_USER/Software/Policies");
应该是
p = p.node("/HKEY_CURRENT_USER/Software/Policies/Microsoft");
这篇关于使用java.util.prefs.Preferences使用Windows注册表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文