• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java recursion  RSS feed

 
Adrian Ronayne
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hello,

I am trying to iterate through all the windows registry keys and values. This is what I have so far but it only seems to iterate one level deep. Im using JNI to access the windows registry - ICE_JNIRegistry.dll.

Thanks for any help.

public void visitAllKeys(RegistryKey key) {
if(key != null){
System.out.println(key.getName());

try{
Enumeration children = key.keyElements();
while(children.hasMoreElements()){
child = key.getName()+"\\"+(String)children.nextElement();
RegistryKey key2 = Registry.openSubkey(Registry.HKEY_CLASSES_ROOT, child, RegistryKey.ACCESS_ALL);
visitAllKeys(key2);
}
}
catch (RegistryException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please UseCodeTags when posting code or configuration. Unformatted code and configuration is very difficult to read. You can edit your post to include them by using the button.

 
Adam Michalik
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know the ICE_JNIRegistry library but I do know ini4j which should do just the same thing and without JNI. You may wish to check it out.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!