I'm trying to read/write windows registry on 64bit Win7 using JAVA.
Firstly, I tried JDK java.util.prefs.Preferences
and its reflection usage. That is a good solution but it only supports reading/writing REG_SZ type (string) value.
Unfortunately, I need to read/write REG_BINARY, so give it up.
Secondly, I tried JNI Registry. Reading is ok, but writing usually fails because writing HKLM needs administrator rights. I don't know how to get administrator rights in JAVA.
Finally, I tried JNA (Java Native Access) an excellent project for working with native libraries and has support for the Windows registry in the platform library (platform.jar) through Advapi32Util
and Advapi32
. It's very good and simple to use. And writing registry needs no administrator rights.
But how can I read/write 32bit Registry (under WOW6432Node node) in a 64bit JVM on Win7?
By default, 64bit nodes are read/written in 64bit JVMs, and 32bit nodes in 32bit JVMs.
But in a 64bit JVM, I want to read/write 32bit nodes(for example, HKLM->SOFTWARE->Wow6432Node->ODBC
). How can I do that?