Prepare to useTo start working with Windows registry from your Java application WinRegistry.dll file should be discoverable
by JVM. You can do it either by adding path to this file to your PATH set PATH="Directory with WinRegistry.dll";%PATH%
or by copying WinRegistry.dll to your Windows directory or by running java with parameter "java.library.path"
java -cp dist/jndi2r.jar;... -Djava.library.path="Directory with WinRegistry.dll" ...
jndi2r.jar should be added to the classpath. Our service provider is tested to work with JDK1.3 and JDK1.4
and on Windows XP/2000/NT/Me/9x
Embedding in your Java applicationsTo enable registry operations in your application you should create InitialContext.
This can be done as follows:
Hashtable environment = new Hashtable();
environment.put("java.naming.factory.initial",
"com.scand.jndi.registry.RegistryInitialContextFactory");
Context c = new InitialContext(environment);
Environment parameters
You can pass the following additional environment parameters:
Names in Registry are not case sensitive ("key" and "KEY" is the same).
For more convenient use the following name aliases are defined:
"HKEY_CLASSES_ROOT" is aliased to "HKCR"
"HKEY_CURRENT_CONFIG" is aliased to "HKCC"
"HKEY_CURRENT_USER" is aliased to "HKCU"
"HKEY_LOCAL_MACHINE" is aliased to "HKLM"
"HKEY_USERS" is aliased to "HKU"
Supported registry types
Service provider has support of common registry types: REG_SZ (mapped to java.lang.String),
REG_DWORD (mapped to java.lang.Long) and REG_BINARY (mapped to com.scand.jndi.registry.ByteArray).
You can also store any serialized java object as REG_BINARY. Support of other types will be in the next release.
Demo version restrictions
In demo version you can create keys/values and read them but you cannot delete them or modify value's content
(OperationNotSupported exception will be thrown).
Samples
For more information see
com.scand.jndi.registry.demo.simple.Simple.java, com.scand.jndi.registry.demo.RegEdit.java
and API documentation. You can run demo RegEdit program as java -jar RegEdit.jar
Also you can use JNDI Browser that can be downloaded from http://java.sun.com/products/jndi.
It should be run as follows:
java -cp "jndibrowser.jar;jndi2r.jar" examples.browser.Browser
"Registry|com.scand.jndi.registry.RegistryInitialContextFactory"
Before running example programs make sure WinRegistry.dll is in your PATH.
API Documentation
API Documentation is included in the distribution. Also it can be found here.
Bug reports or feature requests
If you found bugs or need feature that is not yet implemented, feel free to contact us at info@scand.com.
|