Saturday, May 21, 2011

Windows Registry API for Windows (plus 64-bit)

Lately I was required to provide a solution that needs access to the Windows Registry Keys. I could easily use the command line tools for this end (reg export or something like this). For some reason I found several glitches with this method, mainly around performance and parsing incompatibilities. So I decided to use this library JNIRegistry - "Windows Registry API Native Interface" (

Problem is that it is only compatible with 32 bit and if you are under 64 bit Java, it won't be any good for you. So I had to compile this JNIRegistry library for 64bit. I used Visual Studio 2010 with the Microsoft SDKs 7.1 to compile it with x86_64 compiler. It was a damn nice adventure...

So if you get this error message "ICE_JNIRegistry.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform" you should probably use the second one here:

1. ICE_JNIRegistry.dll for 32 bit

2. ICE_JNIRegistry for 64bit

3. The JNIRegistry library jar

Enjoy ;)

EDIT: one thing I found while using this library under 64bit. you will need to add the "WOW6432node" child if you look for a software-type key. See this article from MS


Holger said...

Thanks for the JNIRegistry link. I used jRegistry which also not works with a 64-bit JRE.

Unfortunately, I get an UnsatisfiedLinkError: "Can't find dependent libraries" (tested on Windows Server 2008 R2 Standard, 64-bit). I'm also wondering why the size of the 64-bit DLL is half of the 32-bit DLL.

Cross-compiled with MinGW-w64 it seems to work:
x86_64-w64-mingw32-gcc-4.7.0.exe -I "<%java_sdk_64-bit%>/include" -I "<%java_sdk_64-bit%>/include/win32" -shared -Wl,--add-stdcall-alias -o "<%output-dir%>\ICE_JNIRegistry64.dll" "<%source-dir%>\RegistryKey.c"

I failed to compile jRegistry which is C++, not C. Fortunately, now I can use JNIRegistry instead of jRegistry to build a 64-bit Open with Eclipse version. :-)

Chaya said...

Thanks Holger for you post, will be great if you share the dll so others who don't want to use my 64 bit Microsoft c compiler based version will be happy as well

Holger said...

Sure, here the JNIRegistry with both DLLs as Eclipse plug-in: