de.humatic.dsj.ext
Class Registry

java.lang.Object
  extended by de.humatic.dsj.ext.Registry

public class Registry
extends java.lang.Object

Collection of static methods to read and manipulate values in the Windows registry.
This is not meant to be a fully featured java registry tool, but in first hand thought for manipulating registry controlled DirectShow filters. Within its limitations you may however use it for more general tasks as well.


Field Summary
static int E_ACCESS_DENIED
           
static int E_KEY_NOT_FOUND
           
static int HKEY_CLASSES_ROOT
           
static int HKEY_CURRENT_CONFIG
           
static int HKEY_CURRENT_USER
           
static int HKEY_LOCAL_MACHINE
           
static int HKEY_USERS
           
static int KEY_ALL_ACCESS
           
static int KEY_CREATE_LINK
           
static int KEY_CREATE_SUB_KEY
           
static int KEY_ENUMERATE_SUB_KEYS
           
static int KEY_NOTIFY
           
static int KEY_QUERY_VALUE
           
static int KEY_SET_VALUE
           
static int KEY_TYPE_BINARY
           
static int KEY_TYPE_INT
           
static int KEY_TYPE_STRING
           
static int KEY_WRITE
           
static int SUCCESS
           
 
Constructor Summary
Registry()
           
 
Method Summary
static int createKey(int majorKey, java.lang.String path)
          Creates a new key at %path under majorKey.
static int createKeyValue(int majorKey, java.lang.String path, java.lang.String valueName, int dataType)
          Creates a value entry of specified type in the key pointed to by %path under majorKey.
static int deleteKey(int majorKey, java.lang.String path)
          Deletes key at %path and all of its value entries.
static int deleteKeyValue(int majorKey, java.lang.String path, java.lang.String valueName)
          Deletes a value entry in key at %path.
static KeyValue[] getKeyValues(int majorKey, java.lang.String path)
          Returns all entries stored under the given path as KeyValue objects.
static byte[] getSubKeyValue_Binary(int majorKey, java.lang.String path, java.lang.String valueName)
           
static int getSubKeyValue_Int(int majorKey, java.lang.String path, java.lang.String valueName)
          Gets a subkey's int value.
static java.lang.String getSubKeyValue_String(int majorKey, java.lang.String path, java.lang.String valueName)
          Gets a subkey's String value.
static int getSubKeyValueType(int majorKey, java.lang.String path, java.lang.String subKeyName)
          Returns KEY_TYPE_INT if key value is of any REG_DWORD type, KEY_TYPE_BINARY for raw data and KEY_TYPE_STRING for REG_SZ string types.
Before querying for a key value, call this method to determine the type of data to expect on return.
static int isKeyAccessible(int majorKey, java.lang.String path)
          Returns 0 if key is accessible, errorcode otherwise.
static int isSubKeyAccessible(int majorKey, java.lang.String path, java.lang.String subKeyName)
          Returns 0 if subkey (value entry) is accessible, errorcode otherwise.
static int setAccessLevel(int level)
          Sets the access rights to open a key with.
static void setKeyValue(int majorKey, java.lang.String path, KeyValue kv)
           
static void setKeyValues(int majorKey, java.lang.String path, KeyValue[] kv)
           
static void setSubKeyValue_Binary(int majorKey, java.lang.String path, java.lang.String subKeyName, byte[] data)
           
static void setSubKeyValue_Int(int majorKey, java.lang.String path, java.lang.String subKeyName, int dwordValue)
          Sets a subkey's DWORD value.
static void setSubKeyValue_String(int majorKey, java.lang.String path, java.lang.String subKeyName, java.lang.String stringValue)
          Sets a subkey's String value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HKEY_CLASSES_ROOT

public static final int HKEY_CLASSES_ROOT
See Also:
Constant Field Values

HKEY_CURRENT_USER

public static final int HKEY_CURRENT_USER
See Also:
Constant Field Values

HKEY_LOCAL_MACHINE

public static final int HKEY_LOCAL_MACHINE
See Also:
Constant Field Values

HKEY_USERS

public static final int HKEY_USERS
See Also:
Constant Field Values

HKEY_CURRENT_CONFIG

public static final int HKEY_CURRENT_CONFIG
See Also:
Constant Field Values

SUCCESS

public static final int SUCCESS
See Also:
Constant Field Values

E_KEY_NOT_FOUND

public static final int E_KEY_NOT_FOUND
See Also:
Constant Field Values

E_ACCESS_DENIED

public static final int E_ACCESS_DENIED
See Also:
Constant Field Values

KEY_TYPE_INT

public static final int KEY_TYPE_INT
See Also:
Constant Field Values

KEY_TYPE_STRING

public static final int KEY_TYPE_STRING
See Also:
Constant Field Values

KEY_TYPE_BINARY

public static final int KEY_TYPE_BINARY
See Also:
Constant Field Values

KEY_ALL_ACCESS

public static final int KEY_ALL_ACCESS
See Also:
Constant Field Values

KEY_QUERY_VALUE

public static final int KEY_QUERY_VALUE
See Also:
Constant Field Values

KEY_SET_VALUE

public static final int KEY_SET_VALUE
See Also:
Constant Field Values

KEY_CREATE_SUB_KEY

public static final int KEY_CREATE_SUB_KEY
See Also:
Constant Field Values

KEY_ENUMERATE_SUB_KEYS

public static final int KEY_ENUMERATE_SUB_KEYS
See Also:
Constant Field Values

KEY_NOTIFY

public static final int KEY_NOTIFY
See Also:
Constant Field Values

KEY_CREATE_LINK

public static final int KEY_CREATE_LINK
See Also:
Constant Field Values

KEY_WRITE

public static final int KEY_WRITE
See Also:
Constant Field Values
Constructor Detail

Registry

public Registry()
Method Detail

setAccessLevel

public static int setAccessLevel(int level)
Sets the access rights to open a key with. By default this is KEY_ALL_ACCESS. However access may not be granted fully on HKEY_LOCAL_MACHINE etc. when on Vista or user has restricted rights. In order to be able to at least read a key, use this method to set a lower access level. The set level will remain in effect until this method is called again.


isKeyAccessible

public static int isKeyAccessible(int majorKey,
                                  java.lang.String path)
Returns 0 if key is accessible, errorcode otherwise.


isSubKeyAccessible

public static int isSubKeyAccessible(int majorKey,
                                     java.lang.String path,
                                     java.lang.String subKeyName)
Returns 0 if subkey (value entry) is accessible, errorcode otherwise.


getKeyValues

public static KeyValue[] getKeyValues(int majorKey,
                                      java.lang.String path)
Returns all entries stored under the given path as KeyValue objects.


setKeyValue

public static void setKeyValue(int majorKey,
                               java.lang.String path,
                               KeyValue kv)
                        throws DSJException
Throws:
DSJException

setKeyValues

public static void setKeyValues(int majorKey,
                                java.lang.String path,
                                KeyValue[] kv)
                         throws DSJException
Throws:
DSJException

getSubKeyValueType

public static int getSubKeyValueType(int majorKey,
                                     java.lang.String path,
                                     java.lang.String subKeyName)
                              throws DSJException
Returns KEY_TYPE_INT if key value is of any REG_DWORD type, KEY_TYPE_BINARY for raw data and KEY_TYPE_STRING for REG_SZ string types.
Before querying for a key value, call this method to determine the type of data to expect on return. Then call the appropriate getKeyValue.. method.
Throws DSJException when key is not accessible.

Throws:
DSJException

getSubKeyValue_Int

public static int getSubKeyValue_Int(int majorKey,
                                     java.lang.String path,
                                     java.lang.String valueName)
                              throws DSJException
Gets a subkey's int value. Throws DSJException if the key or value entry do not exist or are not accessible due to access right limitations.

Throws:
DSJException

getSubKeyValue_String

public static java.lang.String getSubKeyValue_String(int majorKey,
                                                     java.lang.String path,
                                                     java.lang.String valueName)
                                              throws DSJException
Gets a subkey's String value. Throws DSJException if the key or value entry do not exist or are not accessible due to access right limitations.

Throws:
DSJException

getSubKeyValue_Binary

public static byte[] getSubKeyValue_Binary(int majorKey,
                                           java.lang.String path,
                                           java.lang.String valueName)
                                    throws DSJException
Throws:
DSJException

setSubKeyValue_Int

public static void setSubKeyValue_Int(int majorKey,
                                      java.lang.String path,
                                      java.lang.String subKeyName,
                                      int dwordValue)
                               throws de.humatic.dsj.ext.Registry.RegistryException
Sets a subkey's DWORD value. If the subkey does not exist, this method will try to create it.

Throws:
de.humatic.dsj.ext.Registry.RegistryException

setSubKeyValue_String

public static void setSubKeyValue_String(int majorKey,
                                         java.lang.String path,
                                         java.lang.String subKeyName,
                                         java.lang.String stringValue)
                                  throws de.humatic.dsj.ext.Registry.RegistryException
Sets a subkey's String value. If the subkey does not exist, this method will try to create it.

Throws:
de.humatic.dsj.ext.Registry.RegistryException

setSubKeyValue_Binary

public static void setSubKeyValue_Binary(int majorKey,
                                         java.lang.String path,
                                         java.lang.String subKeyName,
                                         byte[] data)
                                  throws de.humatic.dsj.ext.Registry.RegistryException
Throws:
de.humatic.dsj.ext.Registry.RegistryException

createKey

public static int createKey(int majorKey,
                            java.lang.String path)
Creates a new key at %path under majorKey.


createKeyValue

public static int createKeyValue(int majorKey,
                                 java.lang.String path,
                                 java.lang.String valueName,
                                 int dataType)
Creates a value entry of specified type in the key pointed to by %path under majorKey.


deleteKey

public static int deleteKey(int majorKey,
                            java.lang.String path)
Deletes key at %path and all of its value entries.


deleteKeyValue

public static int deleteKeyValue(int majorKey,
                                 java.lang.String path,
                                 java.lang.String valueName)
Deletes a value entry in key at %path.