views:

168

answers:

1

Hi!

I have some questions about the registry.
We have

Preferences p = Preferences.userRoot();

If we execute

p.nodeExists("/HKEY_CURRENT_USER/Software/Policies/Microsoft")    

it will return true.
After it:

p = p.node("/HKEY_CURRENT_USER/Software/Policies");    
for(String s : p.childrenNames()){
    System.out.println(">" + s);
}

We see that it has one child: "Windows". But

p.nodeExists("/HKEY_CURRENT_USER/Software/Policies/Microsoft/Windows")

returns false. Why?

Thanks.

UPDATE

Ok. I have some mistakes. Let me try again: Why does

p.nodeExists("/HKEY_CURRENT_USER/Software/Policies/Microsoft/Windows") 

return false?

+2  A: 

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

should be

p = p.node("/HKEY_CURRENT_USER/Software/Policies/Microsoft");    
Péter Török
As I understand, when i use "/" i'm always linking from root. But, it doesn't matter. Using next code you'll get same result.Preferences p = Preferences.userRoot();p.nodeExists(.../Microsoft/Windows"); - falsep.nodeExists(.../Microsoft")); - true
Stas
@Stas You are right (according to the API docs). Puzzling... I actually tried to reproduce it on my machine but I couldn't even get as far as you: could only get a totally empty root node :-(
Péter Török
@Stas I guess it might be somehow related to privileges... What OS and JDK you are using?
Péter Török
I'm using Win Xp Pro Sp3 with jdk1.6.0_10. User - admin.
Stas
@Stas That explains why you see those nodes and I don't... Unfortunately I can't log in as admin on my work machine :-(
Péter Török
@Péter TörökThanks for help. I'm solved my promlem in with out it. But, in future, i'll return to this question.
Stas