Acessing windows registry
DescriptionAccessing windows registry keys and values can be of some help integrating a java desktop app into windows. Examples of use are: changing which files should be opened with which programs, reading user preferences, etc. There is a zillion possibilities.
The Registry interface has 3 simple methods for accessing the windows registry - reading a key, adding a key, or editing a key.
public native void editKey(int rootKey, String key, String newvalue); public native void addKey(int rootKey, String key, String newvalue); public native Object readKey(int rootkey, String key);For a further description see the apidoc.
Examples of useIn a mailclient project I have I use the registry interface to register the mailclient as a mailclient app in windows, and, if the user desires, to set the mailclient as the default mailclient in windows. The effect of this is that mailto links will be open my mailclient.
Here is how it looks:
String launch = "mymailer.exe /n mailto:%1"; Registry registry = new Registry(); registry.addKey( Registry.HKEY_CLASSES_ROOT, "mailto\\shell\\open\\command", launch);