devjta / java-registry

Automatically exported from code.google.com/p/java-registry
1 stars 4 forks source link

Problem with W7 and W8 #8

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.  On Windows 8
2.  On Windows 7
3.

What is the expected output? What do you see instead?

Exception in thread "main" java.lang.NullPointerException
    at at.jta.Regor.listKeys(Regor.java:714)
    at at.jta.Regor.listKeys(Regor.java:725)

What version of the product are you using? On what operating system?

4-5

Please provide any additional information below.

Doesn't work on Windows 8 and 7 to read key into KKLM

Original issue reported on code.google.com by jonathan...@gmail.com on 10 Jun 2014 at 8:36

GoogleCodeExporter commented 9 years ago
Well as it works for most other users, could you make an reproduceable 
test/example?

And what is KKLM?

Original comment by bEha...@gmail.com on 16 Jun 2014 at 1:33

GoogleCodeExporter commented 9 years ago
Hello excuse me I made a mistake. I'am talking about HKLM (HKEY_LOCAL_MACHINE).

When I try to read/write a key/value in HKLM, Regor returns to me the value 
"null".

The openKey function returns always null when I try to open a subkey in HKLM.
So it works pretty well in HKEY_CURRENT_USER.

Original comment by jonathan...@gmail.com on 16 Jun 2014 at 2:35

GoogleCodeExporter commented 9 years ago
Found the "bug", but i would call it a problem ;-)
It is due security reasons.. So if your program would run as Adminstrator, it 
should work, but the workaround is to open the reg-key only in read mode!!

Example:
        System.out.println(System.getProperty("java.version") + "_" + System.getProperty("java.vm.version") + "_" + System.getProperty("java.vm.vendor"));
        Regor reg = new Regor();

        Key key = reg.openKey(Regor.HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\Windows", Regor.KEY_READ);

        System.out.println("KEY ITSELF: >> " + key);
        System.out.println("VALUE: >> " + reg.readExpand(key, "SystemDirectory"));

        reg.closeKey(key);

You see, i use the openKey method with 3 parameters, where the 3rd parameter is 
the mode in which the reg-key-handle will be opened. So use: Regor.KEY_READ!
If you just use the method without 3rd parameter, it will use 
Regor.KEY_ALL_ACCESS which will not work and therefore you get "null" as 
returned key.

And if you want to modify the registry, you have to be in Admin-Mode (if I have 
time this summer, I will add these feature in the WinRegistry - so you can run 
it as admin - hopefully it will work in a library, because I use that method in 
some other java-GUI-programs).

Plase report back, if this is what you needed!

Original comment by bEha...@gmail.com on 16 Jun 2014 at 2:46

GoogleCodeExporter commented 9 years ago
Ok, so weird.

I have supposed that the problem came from admin rights and I tested with the 
3rd parameter KEY_READ and it didn't work.

Maybe I was making something wrong because It works now.

Thank you for your reply.

Original comment by jonathan...@gmail.com on 16 Jun 2014 at 2:59

GoogleCodeExporter commented 9 years ago
Well, at least it works for you now ;-)

Original comment by bEha...@gmail.com on 16 Jun 2014 at 3:46