public final class

WinRegistryFullOperation

extends Object
java.lang.Object
   ↳ com.microstrategy.utils.proxy.WinRegistryFullOperation

Summary

Constants
int BINARY_KEY If the registry entry is a binary key - use getKeyType(Key key, String valueName)/ to get the type
int DELETE Security Mask need by openKey - just for delete
int DWORD_KEY If the registry entry is a dword key - use getKeyType(Key key, String valueName)/ to get the type
int ERROR_ACCESS_DENIED
int ERROR_CODE
int ERROR_FILE_NOT_FOUND
int ERROR_SUCCESS
int EXPAND_KEY If the registry entry is a expand string key - use getKeyType(Key key, String valueName)/ to get the type
int KEY_ALL_ACCESS Security Mask need by openKey - highest access to do everything (default access by openkey without security mask)
int KEY_CREATE_SUB_KEY Security Mask need by openKey - for creating sub keys
int KEY_ENUMERATE_SUB_KEYS Security Mask need by openKey - for enum sub keys
int KEY_QUERY_VALUE Security Mask need by openKey - just for querying values
int KEY_READ Security Mask need by openKey - for key reading
int KEY_SET_VALUE Security Mask need by openKey - just for setting values
int KEY_WRITE Security Mask need by openKey - for writing keys
int MAX_KEY_LENGTH
int MAX_VALUE_NAME_LENGTH
int MULTI_KEY If the registry entry is a multi string key - use getKeyType(Key key, String valueName)/ to get the type
int NATIVE_HANDLE
int PLAIN_KEY If the registry entry is a normal string key (plain key) - use getKeyType(Key key, String valueName)/ to get the type
int SUBKEYS_NUMBER
int VALUES_NUMBER
int _HKEY_CLASSES_ROOT the old handle to the HKEY_CLASSES_ROOT registry root node
int _HKEY_CURRENT_USER the old handle to the HEKY_CURRENT_USER registry root node
int _HKEY_LOCAL_MACHINE the old handle to the HKEY_LOCAL_MACHINE registry root node
long serialVersionUID version handle to difference between version - introduced with version 4.5 = 450
Fields
public static final Key HKEY_CLASSES_ROOT the NEW handle to the HKEY_CLASSES_ROOT registry root node
public static final Key HKEY_CURRENT_USER the NEW handle to the HEKY_CURRENT_USER registry root node
public static final Key HKEY_LOCAL_MACHINE the NEW handle to the HKEY_LOCAL_MACHINE registry root node
public static int WAIT_FOR_FILE Time (milliseconds) for waiting for a file to grow (needed for caching and reading dword, binary, multi and expand values)
Public Constructors
WinRegistryFullOperation()
Constructor to handle with windows registry
Public Methods
int _closeKey(int key)
This method is deprecated. use closeKey(Key key) instead of
int _createKey(int key, String subkey)
This method is deprecated. use Key createKey(Key key, String subkey) instead of
int _delKey(int key, String subkey)
This method is deprecated. use int delKey(Key key, String subkey) instead of
int _delValue(int key, String valueName)
This method is deprecated. use int delValue(Key key, String valueName) instead of
byte[] _enumKeys(int key, int subkeyIndex, int maxKeyNameLength)
This method is deprecated. use byte[] enumKeys(Key key, int subkexindex, int maxKeyNameLength) instead of
byte[] _enumValueName(int key, int valueNameIndex, int maxValueNameLength)
This method is deprecated. use byte[] enumValueName(Key key, int valueNameIndex, int maxValueNameLength) instead of
int _flushKey(int key)
This method is deprecated. use int flushKey(Key key) instead of
int[] _getChildInformation(int key)
This method is deprecated. use int[] getChildInformation(Key key) instead of
List _listKeys(int key, String subkey)
This method is deprecated. use List listKeys(Key key, String subkey) instead of
List _listKeys(int key)
This method is deprecated. use List listKeys(Key key) instead of
List _listValueNames(int key)
This method is deprecated. use List listValueNames(Key key) instead of
List _listValueNames(int key, String subkey)
This method is deprecated. use List listValueNames(Key key, String subkey) instead of
int _openKey(int key, String subkey)
This method is deprecated. use openKey(Key key, String subkey) instead of
int _openKey(int key, String subkey, int security_mask)
This method is deprecated. use openKey(Key key, String subkey, int security_mask) instead of
byte[] _readValue(int key, String valueName)
This method is deprecated. use byte[] readValue(Key key, String valueName) instead of
int _setValue(int key, String valueName, String value)
This method is deprecated. use int setValue(Key key, String valueName, String value) instead of
void cacheKeys(Key key)
Method caches a complete key + 1 subkey
void cacheKeys(Key key, int maximumChildren)
Method caches a complete key tree (so the key + subchildren)
int closeKey(Key key)
Close an obtained key for right usage
static String convertStringToHexComma(String plain, boolean appendNullSigns)
Method converts a plain String into a hex comma separated String with 0´s between
Key createKey(Key key, String subkey)
Create new key/subkey in the registry with the specified name Attentition: if the key is successfully returned, you should close and open the key again, because the obtained key doesnt have a high access level (so maybe creating or deleting a key/value wouldn´t be successful)
int delKey(Key key, String subkey)
deletes a key/subkey from the registry
int delValue(Key key, String valueName)
This method is deprecated. use int deleteEntry(Key key, String valueName) instead of
void deleteCaches()
Method deletes all caching values
int deleteEntry(Key key, String valueName)
Method deletes the specified value (YOU CAN ALSO DELETE BINARY, DWORD, MULTI OR EXPAND ENTRIES!!!)
byte[] enumKeys(Key key, int subkeyIndex, int maxKeyNameLength)
Reading the subkey name out of the registry (to obtain the count and the maxKeyNameLength use getChildInformation method
byte[] enumValueName(Key key, int valueNameIndex, int maxValueNameLength)
Reading every valueName (not only the string value) out of the registry handle (for maximum value index and maxValueNameLength use the getChildInformation method
int flushKey(Key key)
Flush method - dont know what the method exactly does just implemented because i found it in the java sun source
List getCachingKeys()
Method returns all cached Keys
int[] getChildInformation(Key key)
Reads information about the current opened key (use it when you want to enumKey or enumValueName to determine the maximum key length and the count of keys)
int getKeyType(Key key, String valueName)
Method returns the type of the key + valuename
boolean isCachingActive()
Returns if the caching for dword, expand, multi and binary is enabled (you have to use cacheKeys method)
List listKeys(Key key)
Returns all subkeys from the given key
List listKeys(Key key, String subkey)
Returns all subkeys from the given key and subkey
List listValueNames(Key key)
Returns every valueName (not only the String value names)
List listValueNames(Key key, String subkey)
Returns every valueName (not only the String value names)
Key openKey(Key key, String subkey, int security_mask)
Opens a registry key
Key openKey(Key key, String subkey)
Opens a registry key
static String parseHexString(String hexCommaString, boolean deleteNullSigns)
Method converts a hex given String (separated by comma) into a string For Multi entries, every entry ends with HEX 0 so you can split the lines
static String parseValue(byte[] buf)
Method removes the trailing \0 which is returned from the java.dll (just if the last sign is a \0)
String readAnyValueString(Key key, String valueName)
Method reads any value and give it back as a string result - this method can be time consuming, since it determines
String readBinary(Key key, String valueName)
Method reads from the registry a BINARY value - this is made via Runtime.getRuntime().exec(regedit) and is not one of the best methods, but at least it doesnt need a dll
String readDword(Key key, String valueName)
Method reads the dword entry from the registry
String readExpand(Key key, String valueName)
Method reads an expand string entry
String readMulti(Key key, String valueName)
Method reads a multi string entry from the registry
byte[] readValue(Key key, String valueName)
Reads the value of a string value (DO NOT USE THIS METHOD FOR READING BINARY, DWORD, MULTI OR EXPAND ENTRIES - JUST FOR SZ - STRING ENTRIES!!!)
String readValueAsString(Key key, String valueName)
Reads the value of a string value (DO NOT USE THIS METHOD FOR READING BINARY, DWORD, MULTI OR EXPAND ENTRIES - JUST FOR SZ - STRING ENTRIES!!!)
void refreshCaches()
Method refreshes the cached entries
void saveBinary(Key key, String valueName, String hexCommaData)
This method is deprecated. use savePlainBinary instead of this method
void saveDword(Key key, String valueName, String hexData)
Method saves a dword entry in the registry
void saveExpand(Key key, String valueName, String hexCommaZeroData)
This method is deprecated. use savePlainExpand instead of
void saveMulti(Key key, String valueName, String hexCommaZeroData)
This method is deprecated. use savePlainMulti instead of
void savePlainBinary(Key key, String valueName, String plainData)
Method saves a binary entry for the given key, valuename and data
void savePlainExpand(Key key, String valueName, String plainData)
Method saves an expand string entry
void savePlainMulti(Key key, String valueName, String plainData)
Method saves a multi string entry in the registry
int saveValue(Key key, String valueName, String value)
Method saves the specified string value (DO NOT USE THIS METHOD FOR READING BINARY, DWORD, MULTI OR EXPAND ENTRIES - JUST FOR SZ - STRING ENTRIES!!!) Method saves or create a simple character sequence (REG_SZ) If you want to change the default Value the valueName has to be null or nothing
void setCaching(boolean aValue)
Enables the caching method for dword, expand, multi and binary for the cacheKeys method and then for reading it
int setValue(Key key, String valueName, String value)
This method is deprecated. use saveValue instead of - just changed name
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int BINARY_KEY

If the registry entry is a binary key - use getKeyType(Key key, String valueName)/ to get the type

Constant Value: 2 (0x00000002)

public static final int DELETE

Security Mask need by openKey - just for delete

Constant Value: 65536 (0x00010000)

public static final int DWORD_KEY

If the registry entry is a dword key - use getKeyType(Key key, String valueName)/ to get the type

Constant Value: 3 (0x00000003)

public static final int ERROR_ACCESS_DENIED

Constant Value: 5 (0x00000005)

public static final int ERROR_CODE

Constant Value: 1 (0x00000001)

public static final int ERROR_FILE_NOT_FOUND

Constant Value: 2 (0x00000002)

public static final int ERROR_SUCCESS

Constant Value: 0 (0x00000000)

public static final int EXPAND_KEY

If the registry entry is a expand string key - use getKeyType(Key key, String valueName)/ to get the type

Constant Value: 5 (0x00000005)

public static final int KEY_ALL_ACCESS

Security Mask need by openKey - highest access to do everything (default access by openkey without security mask)

Constant Value: 983103 (0x000f003f)

public static final int KEY_CREATE_SUB_KEY

Security Mask need by openKey - for creating sub keys

Constant Value: 4 (0x00000004)

public static final int KEY_ENUMERATE_SUB_KEYS

Security Mask need by openKey - for enum sub keys

Constant Value: 8 (0x00000008)

public static final int KEY_QUERY_VALUE

Security Mask need by openKey - just for querying values

Constant Value: 1 (0x00000001)

public static final int KEY_READ

Security Mask need by openKey - for key reading

Constant Value: 131097 (0x00020019)

public static final int KEY_SET_VALUE

Security Mask need by openKey - just for setting values

Constant Value: 2 (0x00000002)

public static final int KEY_WRITE

Security Mask need by openKey - for writing keys

Constant Value: 131078 (0x00020006)

public static final int MAX_KEY_LENGTH

Constant Value: 3 (0x00000003)

public static final int MAX_VALUE_NAME_LENGTH

Constant Value: 4 (0x00000004)

public static final int MULTI_KEY

If the registry entry is a multi string key - use getKeyType(Key key, String valueName)/ to get the type

Constant Value: 4 (0x00000004)

public static final int NATIVE_HANDLE

Constant Value: 0 (0x00000000)

public static final int PLAIN_KEY

If the registry entry is a normal string key (plain key) - use getKeyType(Key key, String valueName)/ to get the type

Constant Value: 1 (0x00000001)

public static final int SUBKEYS_NUMBER

Constant Value: 0 (0x00000000)

public static final int VALUES_NUMBER

Constant Value: 2 (0x00000002)

public static final int _HKEY_CLASSES_ROOT

the old handle to the HKEY_CLASSES_ROOT registry root node

Constant Value: -2147483648 (0x80000000)

public static final int _HKEY_CURRENT_USER

the old handle to the HEKY_CURRENT_USER registry root node

Constant Value: -2147483647 (0x80000001)

public static final int _HKEY_LOCAL_MACHINE

the old handle to the HKEY_LOCAL_MACHINE registry root node

Constant Value: -2147483646 (0x80000002)

public static final long serialVersionUID

version handle to difference between version - introduced with version 4.5 = 450

Constant Value: 450 (0x00000000000001c2)

Fields

public static final Key HKEY_CLASSES_ROOT

the NEW handle to the HKEY_CLASSES_ROOT registry root node

public static final Key HKEY_CURRENT_USER

the NEW handle to the HEKY_CURRENT_USER registry root node

public static final Key HKEY_LOCAL_MACHINE

the NEW handle to the HKEY_LOCAL_MACHINE registry root node

public static int WAIT_FOR_FILE

Time (milliseconds) for waiting for a file to grow (needed for caching and reading dword, binary, multi and expand values)

Public Constructors

public WinRegistryFullOperation ()

Constructor to handle with windows registry

Throws
RegistryErrorException throws an registryerrorException when its not able to get a handle to the registry methods
NotSupportedOSException throws an notSupportedOSException if the registry is not used in windows

Public Methods

public int _closeKey (int key)

This method is deprecated.
use closeKey(Key key) instead of

Close an obtained key for right usage

Parameters
key the key handle
Returns
  • int on error it will be -1
Throws
RegistryErrorException
RegistryErrorException

public int _createKey (int key, String subkey)

This method is deprecated.
use Key createKey(Key key, String subkey) instead of

Create new key/subkey in the registry with the specified name Attentition: if the key is successfully returned, you should close and open the key again, because the obtained key doesnt have a high access level (so maybe creating or deleting a key/value wouldn´t be successful)

Parameters
key handle to parent key obtained from openKey
subkey name of the key/subkey you want to create
Returns
  • on success the handle to the new key will be returned, otherwhise it will be -1
Throws
RegistryErrorException
RegistryErrorException

public int _delKey (int key, String subkey)

This method is deprecated.
use int delKey(Key key, String subkey) instead of

deletes a key/subkey from the registry

Parameters
key the parent key obtained by openKey
subkey the key name you want to delete
Returns
  • int ERROR_SUCCESS wenn erfolgreich
Throws
RegistryErrorException if subkey is empty or null or any other exception occurs

public int _delValue (int key, String valueName)

This method is deprecated.
use int delValue(Key key, String valueName) instead of

Method deletes the specified value (YOU CAN ALSO DELETE BINARY, DWORD, MULTI OR EXPAND ENTRIES!!!)

Parameters
key the key obtained by openKey
valueName name of String value you want to delete (if the string is empty or null the default entry will be cleared)
Returns
  • int
Throws
RegistryErrorException
RegistryErrorException

public byte[] _enumKeys (int key, int subkeyIndex, int maxKeyNameLength)

This method is deprecated.
use byte[] enumKeys(Key key, int subkexindex, int maxKeyNameLength) instead of

Reading the subkey name out of the registry (to obtain the count and the maxKeyNameLength use getChildInformation method

Parameters
key the handle to the key obtained by openKey
subkeyIndex index from the subkey from which you want to obtain the name (start with 0 - the maximum count you get from getChildInformation method in array [0])
maxKeyNameLength the maximum length of a subkey name (used because for memory allocating in the java.dll - if you obtain the size from getChildInformation increase the [3] int array by 1 )
Returns
  • byte[] on error or not found or the maxKeyNameLength is to short it will returns null, on success the name of the subkey
Throws
RegistryErrorException
RegistryErrorException

public byte[] _enumValueName (int key, int valueNameIndex, int maxValueNameLength)

This method is deprecated.
use byte[] enumValueName(Key key, int valueNameIndex, int maxValueNameLength) instead of

Reading every valueName (not only the string value) out of the registry handle (for maximum value index and maxValueNameLength use the getChildInformation method

Parameters
key the handle to the parent key obtained from openKey
valueNameIndex the index of the valueName name - starting from 0 going to the maximum count from the getChildInformation stored in array index 2
maxValueNameLength maximum length of valueName name (used because for memory allocating in the java.dll - if you obtain the size from getChildInformation increase the [4] int array by 1)
Returns
  • byte[] either the name of the valueName or null if not found or an error occurs or if the maxValueNameLength is to short
Throws
RegistryErrorException
RegistryErrorException

public int _flushKey (int key)

This method is deprecated.
use int flushKey(Key key) instead of

Flush method - dont know what the method exactly does just implemented because i found it in the java sun source

Parameters
key obtained the key from openKey
Returns
  • on success, ERROR_SUCESS will be returned! on error -1 or sth else
Throws
RegistryErrorException
RegistryErrorException

public int[] _getChildInformation (int key)

This method is deprecated.
use int[] getChildInformation(Key key) instead of

Reads information about the current opened key (use it when you want to enumKey or enumValueName to determine the maximum key length and the count of keys)

Parameters
key the key which you obtained from openKey
Returns
  • int[0] the count of the subkeys,[2] count of valuenames, [3] the maximum length of a subkey! the maximum length of valuename is stored in[4] (for other operations you should increase the [3] or [4] value by 1 because of the terminating \0 in C - because you handle with the java.dll) if nothing found or illegal key, the values are -1 of the array (at index 1 the value would be 6 the other -1)
Throws
RegistryErrorException
RegistryErrorException

public List _listKeys (int key, String subkey)

This method is deprecated.
use List listKeys(Key key, String subkey) instead of

Returns all subkeys from the given key and subkey

Parameters
key either one of the root nodes or a key obtained from openKey
subkey a string to a subkey - if the subkey is empty or null the information will be obtained from the given key
Returns
  • List on success and found a filled list with strings will be returned - on error or nothing found null will be returned
Throws
RegistryErrorException
RegistryErrorException

public List _listKeys (int key)

This method is deprecated.
use List listKeys(Key key) instead of

Returns all subkeys from the given key

Parameters
key either one of the root nodes or a key obtained from openKey
Returns
  • List on success and found a filled list with strings will be returned - on error or nothing found null will be returned
Throws
RegistryErrorException
RegistryErrorException

public List _listValueNames (int key)

This method is deprecated.
use List listValueNames(Key key) instead of

Returns every valueName (not only the String value names)

Parameters
key either one of the root nodes or a key obtained from openKey
Returns
  • List on success and found a filled list with strings will be returned - on error or nothing found null will be returned
Throws
RegistryErrorException
RegistryErrorException

public List _listValueNames (int key, String subkey)

This method is deprecated.
use List listValueNames(Key key, String subkey) instead of

Returns every valueName (not only the String value names)

Parameters
key either one of the root nodes or a key obtained from openKey
subkey a string to a subkey - if the subkey is empty or null the information will be obtained from the given key
Returns
  • List on success and found a filled list with strings will be returned - on error or nothing found null will be returned
Throws
RegistryErrorException
RegistryErrorException

public int _openKey (int key, String subkey)

This method is deprecated.
use openKey(Key key, String subkey) instead of

Opens a registry key

Parameters
key one of the registry root nodes - either HKEY_CLASSES_ROOT, HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE
subkey the name of the key/subkey like SOFTWARE or HARDWARE - for subkeys use the \\ as delimiter f.e. : SOFTWARE\\MICROSOFT if subkey name is "" or null it returns the handle to the root node
Returns
  • int -1 if not found or not allowed (attention here this methods allways uses the KEY_ALL_ACCESS security mask) on success the handle to key will be returned
Throws
RegistryErrorException
RegistryErrorException

public int _openKey (int key, String subkey, int security_mask)

This method is deprecated.
use openKey(Key key, String subkey, int security_mask) instead of

Opens a registry key

Parameters
key one of the registry root nodes - either HKEY_CLASSES_ROOT, HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE
subkey the name of the key/subkey like SOFTWARE or HARDWARE - for subkeys use the \\ as delimiter f.e. : SOFTWARE\\MICROSOFT if subkey name is "" or null it returns the handle to the root node
security_mask the security mask to handle with the opened key (see security mask doc at the begin for detailed information)
Returns
  • int on error -1 (when not found or not allowed) otherwhise the handle to the obtained key
Throws
RegistryErrorException
RegistryErrorException

public byte[] _readValue (int key, String valueName)

This method is deprecated.
use byte[] readValue(Key key, String valueName) instead of

Reads the value of a string value (DO NOT USE THIS METHOD FOR READING BINARY, DWORD, MULTI OR EXPAND ENTRIES - JUST FOR SZ - STRING ENTRIES!!!)

Parameters
key obtained from openKey
valueName the string value which you want to read (if you want to obtain the default entry the valueName should be empty or NULL)
Returns
  • byte[] if found the data in the string value will be returned (to get a string use the class method parseValue(byte[])) on error NULL will be returned
Throws
RegistryErrorException
RegistryErrorException

public int _setValue (int key, String valueName, String value)

This method is deprecated.
use int setValue(Key key, String valueName, String value) instead of

Method set the specified string value (DO NOT USE THIS METHOD FOR READING BINARY, DWORD, MULTI OR EXPAND ENTRIES - JUST FOR SZ - STRING ENTRIES!!!) Methode setzt (oder erstellt) einen Wert auf eine Zeichenfolge Will man den defaulteintrag ändern, so muss man valueName "" übergeben

Parameters
key obtained by openKey
valueName the string value name in the registry you want to set
value the new value you want to set
Returns
  • on success, return is ERROR_SUCCESS if not -1 or sth else will be returned
Throws
RegistryErrorException
RegistryErrorException

public void cacheKeys (Key key)

Method caches a complete key + 1 subkey

Parameters
key Key the registry key which should be cached + subchildren

public void cacheKeys (Key key, int maximumChildren)

Method caches a complete key tree (so the key + subchildren)

Parameters
key Key the registry key which should be cached + subchildren
maximumChildren int amount of the subchildren which should be cached (attention, this may create a java.lang.OutofMemory Error if you have not enoguth memory use -Xmx512M or sth)

public int closeKey (Key key)

Close an obtained key for right usage

Parameters
key the key handle
Returns
  • int on error it will be -1

public static String convertStringToHexComma (String plain, boolean appendNullSigns)

Method converts a plain String into a hex comma separated String with 0´s between

Parameters
plain String
appendNullSigns boolean if you want to add null signs (needed for multi and expand entries, but not for binary entry)
Returns
  • String the converted string

public Key createKey (Key key, String subkey)

Create new key/subkey in the registry with the specified name Attentition: if the key is successfully returned, you should close and open the key again, because the obtained key doesnt have a high access level (so maybe creating or deleting a key/value wouldn´t be successful)

Parameters
key handle to parent key obtained from openKey
subkey name of the key/subkey you want to create
Returns
  • on success the handle to the new key will be returned, otherwhise it will be null

public int delKey (Key key, String subkey)

deletes a key/subkey from the registry

Parameters
key the parent key obtained by openKey
subkey the key name you want to delete
Returns
  • int ERROR_SUCCESS wenn erfolgreich
Throws
RegistryErrorException if subkey is empty or null or any other exception occurs

public int delValue (Key key, String valueName)

This method is deprecated.
use int deleteEntry(Key key, String valueName) instead of

Method deletes the specified value (YOU CAN ALSO DELETE BINARY, DWORD, MULTI OR EXPAND ENTRIES!!!)

Parameters
key the key obtained by openKey
valueName name of String value you want to delete (if the string is empty or null the default entry will be deleted)
Returns
  • int

public void deleteCaches ()

Method deletes all caching values

public int deleteEntry (Key key, String valueName)

Method deletes the specified value (YOU CAN ALSO DELETE BINARY, DWORD, MULTI OR EXPAND ENTRIES!!!)

Parameters
key the key obtained by openKey
valueName name of String value you want to delete (if the string is empty or null the default entry will be cleared)
Returns
  • int

public byte[] enumKeys (Key key, int subkeyIndex, int maxKeyNameLength)

Reading the subkey name out of the registry (to obtain the count and the maxKeyNameLength use getChildInformation method

Parameters
key the handle to the key obtained by openKey
subkeyIndex index from the subkey from which you want to obtain the name (start with 0 - the maximum count you get from getChildInformation method in array [0])
maxKeyNameLength the maximum length of a subkey name (used because for memory allocating in the java.dll - if you obtain the size from getChildInformation increase the [3] int array by 1 )
Returns
  • byte[] on error or not found or the maxKeyNameLength is to short it will returns null, on success the name of the subkey

public byte[] enumValueName (Key key, int valueNameIndex, int maxValueNameLength)

Reading every valueName (not only the string value) out of the registry handle (for maximum value index and maxValueNameLength use the getChildInformation method

Parameters
key the handle to the parent key obtained from openKey
valueNameIndex the index of the valueName name - starting from 0 going to the maximum count from the getChildInformation stored in array index 2
maxValueNameLength maximum length of valueName name (used because for memory allocating in the java.dll - if you obtain the size from getChildInformation increase the [4] int array by 1)
Returns
  • byte[] either the name of the valueName or null if not found or an error occurs or if the maxValueNameLength is to short

public int flushKey (Key key)

Flush method - dont know what the method exactly does just implemented because i found it in the java sun source

Parameters
key obtained the key from openKey
Returns
  • on success, ERROR_SUCESS will be returned! on error -1 or sth else

public List getCachingKeys ()

Method returns all cached Keys

Returns
  • List a list of string of the cached key names

public int[] getChildInformation (Key key)

Reads information about the current opened key (use it when you want to enumKey or enumValueName to determine the maximum key length and the count of keys)

Parameters
key the key which you obtained from openKey
Returns
  • int[0] the count of the subkeys,[2] count of valuenames, [3] the maximum length of a subkey! the maximum length of valuename is stored in[4] (for other operations you should increase the [3] or [4] value by 1 because of the terminating \0 in C - because you handle with the java.dll) if nothing found or illegal key, the values are -1 of the array (at index 1 the value would be 6 the other -1)

public int getKeyType (Key key, String valueName)

Method returns the type of the key + valuename

Parameters
key Key the key handle
valueName String when valueName is empty or null plain key will be returned, because only plain keys can have empty names
Returns
  • int 0 = invalid key or cannot determine keytype, 1 = plain, 2 = binary, 3 = dword, 4 = multi, 5 = expand key - use the definied types *_KEY

public boolean isCachingActive ()

Returns if the caching for dword, expand, multi and binary is enabled (you have to use cacheKeys method)

Returns
  • boolean true or false (default = false)

public List listKeys (Key key)

Returns all subkeys from the given key

Parameters
key either one of the root nodes or a key obtained from openKey
Returns
  • List on success and found a filled list with strings will be returned - on error or nothing found null will be returned

public List listKeys (Key key, String subkey)

Returns all subkeys from the given key and subkey

Parameters
key either one of the root nodes or a key obtained from openKey
subkey a string to a subkey - if the subkey is empty or null the information will be obtained from the given key
Returns
  • List on success and found a filled list with strings will be returned - on error or nothing found null will be returned

public List listValueNames (Key key)

Returns every valueName (not only the String value names)

Parameters
key either one of the root nodes or a key obtained from openKey
Returns
  • List on success and found a filled list with strings will be returned - on error or nothing found null will be returned

public List listValueNames (Key key, String subkey)

Returns every valueName (not only the String value names)

Parameters
key either one of the root nodes or a key obtained from openKey
subkey a string to a subkey - if the subkey is empty or null the information will be obtained from the given key
Returns
  • List on success and found a filled list with strings will be returned - on error or nothing found null will be returned

public Key openKey (Key key, String subkey, int security_mask)

Opens a registry key

Parameters
key one of the registry root nodes - either HKEY_CLASSES_ROOT, HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE
subkey the name of the key/subkey like SOFTWARE or HARDWARE - for subkeys use the \\ as delimiter f.e. : SOFTWARE\\MICROSOFT if subkey name is "" or null it returns the handle to the root node
security_mask the security mask to handle with the opened key (see security mask doc at the begin for detailed information)
Returns
  • Key on NULL (when not found or not allowed) otherwhise the handle to the obtained key (in the Key Object)

public Key openKey (Key key, String subkey)

Opens a registry key

Parameters
key one of the registry root nodes - either HKEY_CLASSES_ROOT, HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE
subkey the name of the key/subkey like SOFTWARE or HARDWARE - for subkeys use the \\ as delimiter f.e. : SOFTWARE\\MICROSOFT if subkey name is "" or null it returns the handle to the root node
Returns
  • Key null if not found or not allowed (attention here this methods allways uses the KEY_ALL_ACCESS security mask) on success the handle to key will be returned

public static String parseHexString (String hexCommaString, boolean deleteNullSigns)

Method converts a hex given String (separated by comma) into a string For Multi entries, every entry ends with HEX 0 so you can split the lines

Parameters
hexCommaString String
deleteNullSigns boolean if you want to remove every 0 sign (delete null signs is needed for multi and expand entries, but not for binary
Returns
  • String

public static String parseValue (byte[] buf)

Method removes the trailing \0 which is returned from the java.dll (just if the last sign is a \0)

Parameters
buf the byte[] buffer which every read method returns
Returns
  • String a parsed string without the trailing \0

public String readAnyValueString (Key key, String valueName)

Method reads any value and give it back as a string result - this method can be time consuming, since it determines

Parameters
key Key
valueName String
Returns
  • String

public String readBinary (Key key, String valueName)

Method reads from the registry a BINARY value - this is made via Runtime.getRuntime().exec(regedit) and is not one of the best methods, but at least it doesnt need a dll

Parameters
key Key the obtained key from the registry
valueName String the valueName of the binary entry which you want to read
Returns
  • String null or the binary data separated by comma
See Also
  • extractAnyValue - method could have a deadlock

public String readDword (Key key, String valueName)

Method reads the dword entry from the registry

Parameters
key Key the parent key handle obtained by openKey
valueName String the dword value
Returns
  • String the dword entry in a hex string
See Also
  • extractAnyValue - method could have a deadlock

public String readExpand (Key key, String valueName)

Method reads an expand string entry

Parameters
key Key the parent key handle obtained by openKey
valueName String the expand value name
Returns
  • String the HEXADECIMAL values separated by comma (use String parseHexString(String) to convert it
See Also
  • extractAnyValue - method could have a deadlock

public String readMulti (Key key, String valueName)

Method reads a multi string entry from the registry

Parameters
key Key the parent key handle obtained by openKey
valueName String the multi value name
Returns
  • String the HEXADECIMAL values separated by comma (use String parseHexString(String) to convert it the line seperator is also a hex null! You have to parse it out
See Also
  • extractAnyValue - method could have a deadlock

public byte[] readValue (Key key, String valueName)

Reads the value of a string value (DO NOT USE THIS METHOD FOR READING BINARY, DWORD, MULTI OR EXPAND ENTRIES - JUST FOR SZ - STRING ENTRIES!!!)

Parameters
key obtained from openKey
valueName the string value which you want to read (if you want to obtain the default entry the valueName should be empty or NULL)
Returns
  • byte[] if found the data in the string value will be returned (to get a string use the class method parseValue(byte[])) on error NULL will be returned

public String readValueAsString (Key key, String valueName)

Reads the value of a string value (DO NOT USE THIS METHOD FOR READING BINARY, DWORD, MULTI OR EXPAND ENTRIES - JUST FOR SZ - STRING ENTRIES!!!)

Parameters
key obtained from openKey
valueName the string value which you want to read (if you want to obtain the default entry the valueName should be empty or NULL)
Returns
  • byte[] if found the data in the string value will be returned (to get a string use the class method parseValue(byte[])) on error NULL will be returned

public void refreshCaches ()

Method refreshes the cached entries

public void saveBinary (Key key, String valueName, String hexCommaData)

This method is deprecated.
use savePlainBinary instead of this method

Method saves a binary entry for the given key, valuename and data

Parameters
key Key The parent key handle obtained by openKey
valueName String the binary value name in the registry
hexCommaData String the string converted in hexadecimal signs separated with commas. Use String convertStringToHexComma(String plainString, false) to get the hex comma separated data
See Also
  • saveAnyValue - method could have a deadlock

public void saveDword (Key key, String valueName, String hexData)

Method saves a dword entry in the registry

Parameters
key Key the parent key handle obtained by openKey
valueName String the valuename of the dword entry
hexData String a hexadecimal String withouth comma or spaces (use Long.toHexString(long) to get a hex string)
See Also
  • saveAnyValue - method could have a deadlock

public void saveExpand (Key key, String valueName, String hexCommaZeroData)

This method is deprecated.
use savePlainExpand instead of

Method saves an expand string entry

Parameters
key Key the parent key handle obtained by openKey
valueName String the expand value name
hexCommaZeroData String the data to write converted in hex string separated by a comma with trailing zeros Use String convertStringToHexComma(String plainString, true) to get the hex comma separated data with 0 signs between
See Also
  • saveAnyValue - method could have a deadlock

public void saveMulti (Key key, String valueName, String hexCommaZeroData)

This method is deprecated.
use savePlainMulti instead of

Method saves a multi string entry in the registry

Parameters
key Key the parent key handle obtained by openKey
valueName String the multi value name
hexCommaZeroData String the data to write converted in hex string separated by a comma with trailing zeros Use String convertStringToHexComma(String plainString, true) to get the hex comma separated data with 0 signs between
See Also
  • saveAnyValue - method could have a deadlock

public void savePlainBinary (Key key, String valueName, String plainData)

Method saves a binary entry for the given key, valuename and data

Parameters
key Key The parent key handle obtained by openKey
valueName String the binary value name in the registry
plainData String like you would see in the registry (without any spaces, etc..)
See Also
  • extractAnyValue - method could have a deadlock

public void savePlainExpand (Key key, String valueName, String plainData)

Method saves an expand string entry

Parameters
key Key the parent key handle obtained by openKey
valueName String the expand value name
plainData String
See Also
  • saveAnyValue - method could have a deadlock

public void savePlainMulti (Key key, String valueName, String plainData)

Method saves a multi string entry in the registry

Parameters
key Key the parent key handle obtained by openKey
valueName String the multi value name
plainData String
See Also
  • saveAnyValue - method could have a deadlock

public int saveValue (Key key, String valueName, String value)

Method saves the specified string value (DO NOT USE THIS METHOD FOR READING BINARY, DWORD, MULTI OR EXPAND ENTRIES - JUST FOR SZ - STRING ENTRIES!!!) Method saves or create a simple character sequence (REG_SZ) If you want to change the default Value the valueName has to be null or nothing

Parameters
key obtained by openKey
valueName the string value name in the registry you want to set
value the new value you want to set
Returns
  • on success, return is ERROR_SUCCESS if not -1 or sth else will be returned

public void setCaching (boolean aValue)

Enables the caching method for dword, expand, multi and binary for the cacheKeys method and then for reading it

Parameters
aValue boolean true or false

public int setValue (Key key, String valueName, String value)

This method is deprecated.
use saveValue instead of - just changed name

Method set the specified string value (DO NOT USE THIS METHOD FOR READING BINARY, DWORD, MULTI OR EXPAND ENTRIES - JUST FOR SZ - STRING ENTRIES!!!) Methode setzt (oder erstellt) einen Wert auf eine Zeichenfolge Will man den defaulteintrag ändern, so muss man valueName "" übergeben

Parameters
key obtained by openKey
valueName the string value name in the registry you want to set
value the new value you want to set
Returns
  • on success, return is ERROR_SUCCESS if not -1 or sth else will be returned