platform
Class WindowsRegistry

java.lang.Object
  extended by platform.WindowsRegistry

public class WindowsRegistry
extends java.lang.Object

Simple wrapper class to access the windows registy. The trick is to access a hidden java class inside the JDK which is available at JDK 1.4

Author:
Christian Banse

Field Summary
private static int ERROR_CODE
           
private static java.lang.reflect.Method ms_closeKeyMethod
           
private static java.lang.reflect.Method ms_openKeyMethod
           
private static java.lang.reflect.Method ms_queryValueMethod
           
private static java.lang.Class ms_windowsPreferencesClass
           
private static int NATIVE_HANDLE
           
 
Constructor Summary
WindowsRegistry()
           
 
Method Summary
static int closeKey(int a_hKey)
          Closes the handle to an opened key.
static int openKey(int a_hKey, java.lang.String a_subKey, int a_securityMask)
          Opens a registry key for further processing.
static java.lang.String queryValue(int a_hKey, java.lang.String a_valueName)
          Queries a certain value of an opened registry key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NATIVE_HANDLE

private static final int NATIVE_HANDLE
See Also:
Constant Field Values

ERROR_CODE

private static final int ERROR_CODE
See Also:
Constant Field Values

ms_windowsPreferencesClass

private static java.lang.Class ms_windowsPreferencesClass

ms_openKeyMethod

private static java.lang.reflect.Method ms_openKeyMethod

ms_queryValueMethod

private static java.lang.reflect.Method ms_queryValueMethod

ms_closeKeyMethod

private static java.lang.reflect.Method ms_closeKeyMethod
Constructor Detail

WindowsRegistry

public WindowsRegistry()
Method Detail

openKey

public static int openKey(int a_hKey,
                          java.lang.String a_subKey,
                          int a_securityMask)
Opens a registry key for further processing.

Parameters:
a_hKey - The key to open (for example WindowsOS.HKEY_CLASSES_ROOT.
a_subKey - The sub key.
a_securityMask - The security mask (for example WindowsOS.KEY_ALL_ACCESS.
Returns:
the native handle to the registry key.

queryValue

public static java.lang.String queryValue(int a_hKey,
                                          java.lang.String a_valueName)
Queries a certain value of an opened registry key. This only works if the value is REG_SZ

Parameters:
a_hKey - The native handle to the key.
a_valueName - The value name.
Returns:
the value of the specified value name.

closeKey

public static int closeKey(int a_hKey)
Closes the handle to an opened key.

Parameters:
a_hKey - The native handle of the key.
Returns:
a windows error code. Returns WindowsOS.ERROR_SUCCESS on success.