99% Java


Acessing windows registry


Accessing 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 use

In 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();


Contributed by Stig Tanggaard. Download it here. Contains a project file for Visual C++ 6 and binaries. The code is GPL and thereby free to use by everyone.

SourceForge.net Logo