public class RegistryKey extends Object implements Cloneable, Comparable<RegistryKey>, Serializable
This is an abstract representation of a key in the Windows Registry. Each key is capable of holding named value-data pairs plus other subkeys in a tree like structure.
This class provides many different methods which allow for the creation
and deletion of subkeys as well as the creation and deletion of values.
Also there are methods which can be used to query the different subkeys
and values which can be found in a key as well as to test for the existence
of keys and values. Methods are also provided which allow the registry key and its
values to be renamed.
There are two different constructors available for use. One is generally used
for when a key already exists in the registry, and the other can be used to
create the key when the constructor is called.
Another way to create an instance of the RegistryKey
class
is through the parseKey
methods. There are two versions of the
method, one which returns a RegistryKey
object if it already exists
in the registry, and the other creates the key as the path is being parsed.
A final set of methods allow the keys to be saved to files, restored from files,
and also to load and unload keys from a registry hive. These methods however require
that the calling process have administrative priviledges, otherwise the methods fail
with ERROR_ACCESS_DENIED
.
Changes to the registry can be tracked using the RegistryListener
and
RegistryWatcher
classes.
NOTE: On some Windows operating systems, the class name parameter may be ignored.
The allowance of this parameter is in order to make the library more complete.
A warning for users who might use the normal deleteKey()
method to delete symbolic link
keys, if that method is used you run the risk of also deleting the key that the link is pointing to.
The deleteLink()
method should be used instead.
Modifier and Type | Field and Description |
---|---|
static int |
ALL_FILTERS
Constant for
RegistryWatcher combining all of the possible filters. |
static int |
DEFAULT_FILTER
Constant for
RegistryWatcher to notify caller if a subkey is added or deleted
or if a value of the key changed. |
static String |
DEFAULT_VALUE_NAME
Constant that represents the name of the default value.
|
static int |
ERROR_ACCESS_DENIED |
static int |
ERROR_ALREADY_EXISTS |
static int |
ERROR_BADDB |
static int |
ERROR_BADKEY |
static int |
ERROR_CANTOPEN |
static int |
ERROR_CANTREAD |
static int |
ERROR_CANTWRITE |
static int |
ERROR_CHILD_MUST_BE_VOLATILE |
static int |
ERROR_CODE
A constant to retrieve the error code from the array returned by
getKeyInfo() . |
static int |
ERROR_FILE_NOT_FOUND |
static int |
ERROR_FILENAME_EXCED_RANGE |
static int |
ERROR_INVALID_HANDLE |
static int |
ERROR_INVALID_PARAMETER |
static int |
ERROR_KEY_DELETED |
static int |
ERROR_KEY_HAS_CHILDREN |
static int |
ERROR_NO_LOG_SPACE |
static int |
ERROR_NO_SYSTEM_RESOURCES |
static int |
ERROR_NOT_REGISTRY_FILE |
static int |
ERROR_OUTOFMEMORY |
static int |
ERROR_PROC_NOT_FOUND |
static int |
ERROR_REGISTRY_CORRUPT |
static int |
ERROR_REGISTRY_IO_FAILED |
static int |
ERROR_SUCCESS |
static int |
HKEY_CLASSES_ROOT_INDEX
The index in the
listRoots() array for the HKEY_CLASSES_ROOT registry key. |
static int |
HKEY_CURRENT_CONFIG_INDEX
The index in the
listRoots() array for the HKEY_CURRENT_CONFIG registry key. |
static int |
HKEY_CURRENT_USER_INDEX
The index in the
listRoots() array for the HKEY_CURRENT_USER registry key. |
static int |
HKEY_DYN_DATA_INDEX
The index in the
listRoots() array for the HKEY_DYN_DATA registry key. |
static int |
HKEY_LOCAL_MACHINE_INDEX
The index in the
listRoots() array for the HKEY_LOCAL_MACHINE registry key. |
static int |
HKEY_PERFORMANCE_DATA_INDEX
The index in the
listRoots() array for the HKEY_PERFORMANCE_DATA registry key. |
static int |
HKEY_USERS_INDEX
The index in the
listRoots() array for the HKEY_USERS registry key. |
static int |
MAX_CHARACTER_LENGTH |
static int |
MAX_CLASS_LENGTH
A constant to retrieve the maximum length of a subkey's class name
from the array returned by
getKeyInfo() . |
static int |
MAX_KEY_LENGTH |
static int |
MAX_SUB_KEY_LENGTH
A constant to retrieve the maximum length of a subkey name
from the array returned by
getKeyInfo() . |
static int |
MAX_VALUE_LENGTH
A constant to retrieve the maximum length of a value's data
from the array returned by
getKeyInfo() . |
static int |
MAX_VALUE_NAME_LENGTH
A constant to retrieve the maximum length of a value's name
from the array returned by
getKeyInfo() . |
static int |
NUM_SUB_KEYS
A constant to retrieve the number of subkeys from the array returned by
getKeyInfo() . |
static int |
NUM_VALUES
A constant to retrieve the number of values from the array returned by
getKeyInfo() . |
static String |
OLD_COPY_TREE
System property for using the old copy tree method instead of the new version.
|
static String |
OLD_DELETE_TREE
System property for using the old delete tree method instead of the new version.
|
static int |
REG_NOTIFY_CHANGE_ATTRIBUTES
Constant for
RegistryWatcher to notify caller of changes
to the attributes of the key, such as the security descriptor information. |
static int |
REG_NOTIFY_CHANGE_LAST_SET
Constant for
RegistryWatcher to notify caller of changes
to a value of the key. |
static int |
REG_NOTIFY_CHANGE_NAME
Constant for
RegistryWatcher to notify caller if a subkey is added or deleted. |
static int |
REG_NOTIFY_CHANGE_SECURITY
Constant for
RegistryWatcher to notify caller of changes
to the security descriptor of the key. |
Constructor and Description |
---|
RegistryKey(RegistryKey root,
String subKey)
Constructs a new
RegistryKey rooted at root
which goes all the way to subKey . |
RegistryKey(RegistryKey root,
String subKey,
boolean create)
Constructs a new
RegistryKey rooted at root
which goes all the way to subKey . |
RegistryKey(RegistryKey root,
String subKey,
boolean create,
boolean nonVolatile)
Constructs a new
RegistryKey rooted at root
which goes all the way to subKey . |
RegistryKey(RegistryKey root,
String subKey,
boolean create,
String clazz)
Constructs a new
RegistryKey rooted at root
which goes all the way to subKey with a specific class name. |
RegistryKey(RegistryKey root,
String subKey,
boolean create,
String clazz,
boolean nonVolatile)
Constructs a new
RegistryKey rooted at root
which goes all the way to subKey with a specific class name. |
RegistryKey(String subKey)
Constructs a new
RegistryKey rooted at HKEY_CURRENT_USER
which goes all the way to subKey . |
RegistryKey(String subKey,
boolean create)
Constructs a new
RegistryKey rooted at HKEY_CURRENT_USER
which goes all the way to subKey . |
RegistryKey(String subKey,
boolean create,
boolean nonVolatile)
Constructs a new
RegistryKey rooted at HKEY_CURRENT_USER
which goes all the way to subKey . |
RegistryKey(String subKey,
boolean create,
String clazz)
Constructs a new
RegistryKey rooted at HKEY_CURRENT_USER
which goes all the way to subKey with a specific class name. |
RegistryKey(String subKey,
boolean create,
String clazz,
boolean nonVolatile)
Constructs a new
RegistryKey rooted at HKEY_CURRENT_USER
which goes all the way to subKey with a specific class name. |
Modifier and Type | Method and Description |
---|---|
static void |
autoExpandEnvironmentVariables(boolean auto)
Specifies whether values of type REG_EXPAND_SZ should have
their values expanded when returned from a call to
getValue(String)
or getValues() . |
boolean |
canDelete()
Tests to see if
this can be deleted. |
boolean |
canDeleteLink()
Tests to see if
this can be deleted. |
boolean |
canDeleteTree()
Tests to see if the subtree rooted at
this can be deleted. |
boolean |
canLoadKey()
Tests to see if
this can load a registry hive. |
boolean |
canRename()
Tests to see if
this can be renamed. |
boolean |
canUnLoadKey()
Tests to see if
this can be unloaded from the registry. |
boolean |
canWrite()
Tests to see if values can be added to
this . |
Object |
clone()
Creates a shallow copy of
this . |
int |
compareTo(RegistryKey o)
Implements the compareTo method in the interface
Comparable . |
static RegistryKey |
connect(String machine,
RegistryKey root)
Connects to a remote registry on the computer named by
machine . |
void |
copy(RegistryKey to)
Deprecated.
|
int |
copySubKeyValue(String subKey,
RegistryKey dest,
RegistryValue value)
Copies the registry value represented by
value within subKey to
the registry key dest . |
int |
copySubKeyValues(String subKey,
RegistryKey dest,
RegistryValue... va)
Copies the set of registry values represented by
va within subKey to
the registry key dest . |
int |
copySubKeyValues(String subKey,
RegistryKey dest,
String... va)
Copies the set of registry values named by
va within subKey to
the registry key dest . |
int |
copySubTree(String subKey,
RegistryKey dest)
Copies all of the subkeys and values from
subkey
to dest . |
int |
copySubTree(String subKey,
RegistryKey dest,
boolean copyLinks)
Copies all of the subkeys and values from
subkey
to dest . |
int |
copyTree(RegistryKey dest)
Copies all of the subkeys and values from
this
to dest . |
int |
copyTree(RegistryKey dest,
boolean copyLinks)
Copies all of the subkeys and values from
this
to dest . |
int |
copyValue(RegistryKey dest,
RegistryValue value)
Copies the registry value represented by
value to
the registry key dest . |
int |
copyValues(RegistryKey dest,
RegistryValue... va)
Copies the set of registry values represented by
va to
the registry key dest . |
int |
copyValues(RegistryKey dest,
String... va)
Copies the set of registry values named by
va to
the registry key dest . |
int |
create()
Creates the key represented by
this in the registry. |
int |
create(boolean nonVolatile)
Creates the key represented by
this in the registry. |
int |
create(String clazz)
Creates the key represented by
this in the registry with the specified class name. |
int |
create(String clazz,
boolean nonVolatile)
Creates the key represented by
this in the registry with the specified class name. |
boolean |
created()
Retrieves whether or not
this was created
or if it already existed in the registry. |
int |
createLink(RegistryKey target)
Creates the key represented by
this in the registry as a link to another key. |
int |
createLink(RegistryKey target,
boolean nonVolatile)
Creates the key represented by
this in the registry as a link to another key. |
int |
createLink(RegistryKey target,
String clazz)
Creates the key represented by
this in the registry with the specified class name
as a link to another key. |
int |
createLink(RegistryKey target,
String clazz,
boolean nonVolatile)
Creates the key represented by
this in the registry with the specified class name
as a link to another key. |
RegistryKey |
createSubKey(String subKey)
Creates a new subkey under
this . |
RegistryKey |
createSubKey(String subKey,
boolean nonVolatile)
Creates a new subkey under
this . |
RegistryKey |
createSubKey(String subKey,
String clazz)
Creates a new subkey under
this with the specified class name. |
RegistryKey |
createSubKey(String subKey,
String clazz,
boolean nonVolatile)
Creates a new subkey under
this with the specified class name. |
RegistryKey |
createSubKeyLink(String subKey,
RegistryKey target)
Creates a new subkey under
this which will link to another key. |
RegistryKey |
createSubKeyLink(String subKey,
RegistryKey target,
boolean nonVolatile)
Creates a new subkey under
this which will link to another key. |
RegistryKey |
createSubKeyLink(String subKey,
RegistryKey target,
String clazz)
Creates a new subkey under
this with the specified class name
as a link to another key. |
RegistryKey |
createSubKeyLink(String subKey,
RegistryKey target,
String clazz,
boolean nonVolatile)
Creates a new subkey under
this with the specified class name
as a link to another key. |
int |
deleteKey()
Deletes
this from the registry. |
static int |
deleteKeys(RegistryKey... keys)
Deletes a set of registry keys from the registry.
|
int |
deleteLink()
Deletes
this symbolic link from the registry. |
static int |
deleteLinks(RegistryKey... keys)
Deletes a set of symbolic link registry keys from the registry.
|
int |
deleteSubKey(String subKey)
Deletes
subKey from this . |
int |
deleteSubKeys(String... subKeys)
Deletes the
subKey s from this . |
int |
deleteSubKeyValue(String subKey,
RegistryValue value)
Deletes a named value represented by
value
from subKey . |
int |
deleteSubKeyValue(String subKey,
String value)
Deletes a named value from
subKey . |
int |
deleteSubKeyValues(String subKey,
RegistryValue... va)
Deletes a set of named values represented by
va
from subKey . |
int |
deleteSubKeyValues(String subKey,
String... va)
Deletes a set of named values within
va
from subKey . |
int |
deleteSubTree(String subKey)
Deletes the entire subtree rooted at
subKey
from the registry.This method uses the Windows Vista implementation for deleting a subtree. |
int |
deleteSubTree(String subKey,
boolean delLinks)
Deletes the entire subtree rooted at
subKey
from the registry.This method uses the Windows Vista implementation for deleting a subtree. |
int |
deleteTree()
Deletes the entire subtree rooted at
this
from the registry. |
int |
deleteTree(boolean delLinks)
Deletes the entire subtree rooted at
this
from the registry. |
int |
deleteValue(RegistryValue value)
Deletes a named value represented by
value
from this . |
int |
deleteValue(String value)
Deletes a named value from
this . |
int |
deleteValues(RegistryValue... va)
Deletes a set of named values represented by
RegistryValues within va
from this . |
int |
deleteValues(String... va)
Deletes a set of named values within
va
from this . |
int |
deleteView64Key(String subKey)
Deletes
subKey from a 64-bit specific view of the registry from this
if isViewing64BitRegistry() is true . |
int |
deleteView64Keys(String... subKeys)
Deletes the
subKey s from a 64-bit specific view of the registry from this
if isViewing64BitRegistry() is true . |
int |
disableReflection()
Disables registry reflection for
this key. |
int |
disableReflectionTree()
Disables registry reflection for
this key and its entire subtree. |
int |
enableReflection()
Enables registry reflection for
this key. |
int |
enableReflectionTree()
Enables registry reflection for
this key and its entire subtree. |
boolean |
equals(Object o)
Tests for equality with another
Object . |
boolean |
exists()
Tests to see if
this exists in the registry. |
static String |
expandEnvironmentVariables(String envStr)
Allows data from values of REG_EXPAND_SZ to be expanded.
|
int |
flushKey()
Writes all attributes of
this into the registry. |
static String |
formatErrorMessage(int code)
Retrieves the description for an error code that was returned
by a method in the
RegistryKey class or one of the
RegistryValue classes. |
String |
getClassName()
Retrieves the class name for
this if it is set. |
static String |
getCurrentUserSid()
Retrieves the current user's SID in
String format. |
int |
getIndex()
Retrieves the index of
this under the parent. |
int[] |
getKeyInfo()
Retrieves information about
this . |
int |
getLastError()
Retrieves the error code from the last open operation
on
this . |
int |
getLevel()
Retrieves the level in the registry that
this resides in. |
RegistryKey |
getLinkLocation()
|
String |
getName()
Used to retrieve the name of
this key. |
int |
getNumberOfSubKeys()
Retrieves the number of subkeys that are under
this . |
int |
getNumberOfValues()
Retrieves the number of values that are in
this . |
RegistryKey |
getParent()
Retrieves the parent
RegistryKey of this . |
String |
getPath()
Retrieves the path in the registry which points to
this . |
static RegistryQuota |
getRegistryQuota()
Retrieves the current size of the registry and the maximum size
that the registry is allowed to attain on the system.
|
int |
getRootIndex()
Retrieves the index of the root key of
this
in the listRoots() array. |
RegistryKey |
getRootKey()
Retrieves the root key for
this . |
static RegistryKey |
getRootKeyForIndex(int index)
Retrieves the root key based on the HKEY_*_INDEX values.
|
RegistryKey |
getSubKey(String name)
Retrieves a
RegistryKey which represents the subkey
with a name of name under this . |
String[] |
getSubKeyNames()
Retrieves a sorted array of
String s which
are the names of the subkeys under this . |
List<RegistryKey> |
getSubKeys()
Retrieves a list of
RegistryKey s which represent the subkeys
that are under this . |
List<RegistryKey> |
getSubKeys(String... subKeys)
Retrieves a list of
RegistryKey s which are specified by the names in subKeys
that are under this . |
SystemTime |
getSystemTime()
Retrieves the last write time of
this as
a SystemTime object. |
RegistryValue |
getValue(String name)
|
String[] |
getValueNames()
Retrieves a sorted array of
String s which
are the names of the values under this . |
List<RegistryValue> |
getValues()
Retrieves a list of
RegistryValue s which represent the values
that are under this . |
List<RegistryValue> |
getValues(String... va)
Retrieves a list of
RegistryValue s which represent the values
that are named by va . |
static ValueType |
getValueType(int type)
Convenience method to retrieve the
ValueType object based
on the integer type that is passed in. |
boolean |
hasDefaultValue()
Convenience method to test to see if
this
contains the default or unnamed value. |
int |
hashCode()
Calculates the hash code value for
this . |
boolean |
hasSubKeys()
Convenience method to test to see if
this
contains any subkeys. |
boolean |
hasValues()
Convenience method to test to see if
this
contains any values. |
static boolean |
isAutoExpandEnvironmentVariables()
Determines whether values of type REG_EXPAND_SZ have
their values automatically expanded when returned from a call to
getValue(String)
or getValues() . |
boolean |
isLinkKey()
Checks to see whether
this key is a symbolic link
to another key. |
boolean |
isRemoteRegistryKey()
Checks to see whether
this key is a remote registry key. |
boolean |
isViewing64BitRegistry()
Determines if the key is viewing the 64-bit registry or the 32-bit registry.
|
boolean |
keyExists(String subKey)
Tests to see if the specified subkey
exists under
this . |
boolean |
keyIsLink(String subKey)
Tests to see if the specified subkey
under
this is a link. |
long |
lastModified()
Returns the time that the key denoted by
this was last modified. |
static RegistryKey[] |
listRoots()
Retrieves an array of all the registry root keys.
|
int |
loadKey(String subKey,
File regFile)
Creates a subkey under HKEY_USERS or HKEY_LOCAL_MACHINE and
loads the data from the specified registry hive into that subkey.
|
RegistryValue |
newValue(String name,
int type)
Creates a new value under
this with the specified
name and type. |
RegistryValue |
newValue(String name,
ValueType type)
Creates a new value under
this with the specified
name and type. |
static RegistryKey |
parseKey(String key)
Tranforms the
String path of a registry key into
a RegistryKey object. |
static RegistryKey |
parseKey(String key,
boolean create)
Tranforms the
String path of a registry key into
a RegistryKey object. |
static RegistryKey |
parseKey(String key,
boolean create,
boolean nonVolatile)
Tranforms the
String path of a registry key into
a RegistryKey object. |
boolean |
queryReflection()
Determines whether registry reflection for
this key is turned off. |
boolean |
renameKey(String newKeyName)
Renames
this to newKeyName . |
boolean |
renameValue(RegistryValue old,
String newValueName)
Renames the value specified by
old to newValueName . |
boolean |
renameValue(String old,
String newValueName)
Renames the value specified by the name
old to newValueName . |
int |
replaceKey(File newRegFile,
File oldRegFile)
Replaces the file backing
this key and all the subkeys with another file,
so that when the system is next started, the key and subkeys will have the values
stored in the new file. |
int |
replaceSubKey(String subKey,
File newRegFile,
File oldRegFile)
Replaces the file backing the subkey of
this key and all its subkeys with another file,
so that when the system is next started, the key and subkeys will have the values
stored in the new file. |
int |
restoreKey(File regFile)
Reads the registry information in a specified file and copies it
over
this key. |
int |
restoreKey(File regFile,
boolean force)
Reads the registry information in a specified file and copies it
over
this key. |
int |
saveKey(boolean latest,
boolean noCompress,
File regFile)
Saves
this and all subkeys and values to a new file, in the specified format. |
int |
saveKey(File regFile)
Saves
this and all subkeys and values to a new file, in the standard format. |
int |
searchBinaryValue(int startIndex,
byte[] value)
Allows
this key's binary values (REG_NONE, REG_BINARY, etc.)
to be searched for a particular value. |
int |
searchIntegerValue(int startIndex,
long value)
Allows
this key's integer values (REG_DWORD and REG_QWORD, etc.)
to be searched for a particular value. |
int |
searchStringValue(int startIndex,
boolean valueName,
boolean data,
boolean matchStr,
String key)
Allows
this key's string values (REG_SZ, REG_EXPAND_SZ and REG_MULTI_SZ)
to be searched for a particular value. |
int |
searchStringValue(int startIndex,
String key)
Allows
this key's string values (REG_SZ, REG_EXPAND_SZ and REG_MULTI_SZ)
to be searched for a particular value. |
boolean |
setLinkTo(RegistryKey target)
If
this represents a symbolic link, then the target for this
will be changed to the key represented by target . |
Iterator<String> |
subKeyNamesIterator()
|
Iterator<RegistryKey> |
subKeysIterator()
|
String |
toNativePath()
Retrieves the
String representation of this
using the native registry api format. |
String |
toString()
Retrieve a
String representation of this . |
int |
unLoadKey()
Unloads
this and all subkeys and values from the registry. |
boolean |
valueExists(String value)
Tests to see if the specified value exists under
this . |
Iterator<String> |
valueNamesIterator()
|
Iterator<RegistryValue> |
valuesIterator()
|
void |
view64BitRegistry(boolean view64)
Specifies whether the key should look into the 64-bit registry or the 32-bit registry
This method does nothing on Windows 2000 systems.
|
public static final int ERROR_CODE
getKeyInfo()
.public static final int NUM_SUB_KEYS
getKeyInfo()
.public static final int MAX_SUB_KEY_LENGTH
getKeyInfo()
.public static final int MAX_CLASS_LENGTH
getKeyInfo()
.public static final int NUM_VALUES
getKeyInfo()
.public static final int MAX_VALUE_NAME_LENGTH
getKeyInfo()
.public static final int MAX_VALUE_LENGTH
getKeyInfo()
.public static final int ERROR_SUCCESS
public static final int ERROR_FILE_NOT_FOUND
public static final int ERROR_ACCESS_DENIED
public static final int ERROR_INVALID_HANDLE
public static final int ERROR_OUTOFMEMORY
public static final int ERROR_INVALID_PARAMETER
public static final int ERROR_PROC_NOT_FOUND
public static final int ERROR_ALREADY_EXISTS
public static final int ERROR_FILENAME_EXCED_RANGE
public static final int ERROR_BADDB
public static final int ERROR_BADKEY
public static final int ERROR_CANTOPEN
public static final int ERROR_CANTREAD
public static final int ERROR_CANTWRITE
public static final int ERROR_REGISTRY_CORRUPT
public static final int ERROR_REGISTRY_IO_FAILED
public static final int ERROR_NOT_REGISTRY_FILE
public static final int ERROR_KEY_DELETED
public static final int ERROR_NO_LOG_SPACE
public static final int ERROR_KEY_HAS_CHILDREN
public static final int ERROR_CHILD_MUST_BE_VOLATILE
public static final int ERROR_NO_SYSTEM_RESOURCES
public static final int MAX_KEY_LENGTH
public static final int MAX_CHARACTER_LENGTH
public static final int REG_NOTIFY_CHANGE_NAME
RegistryWatcher
to notify caller if a subkey is added or deleted.public static final int REG_NOTIFY_CHANGE_ATTRIBUTES
RegistryWatcher
to notify caller of changes
to the attributes of the key, such as the security descriptor information.public static final int REG_NOTIFY_CHANGE_LAST_SET
RegistryWatcher
to notify caller of changes
to a value of the key. This can include adding or deleting a value,
or changing an existing value.public static final int REG_NOTIFY_CHANGE_SECURITY
RegistryWatcher
to notify caller of changes
to the security descriptor of the key.public static final int DEFAULT_FILTER
RegistryWatcher
to notify caller if a subkey is added or deleted
or if a value of the key changed.public static final int ALL_FILTERS
RegistryWatcher
combining all of the possible filters.public static final String DEFAULT_VALUE_NAME
public static final int HKEY_CLASSES_ROOT_INDEX
listRoots()
array for the HKEY_CLASSES_ROOT registry key.public static final int HKEY_CURRENT_USER_INDEX
listRoots()
array for the HKEY_CURRENT_USER registry key.public static final int HKEY_LOCAL_MACHINE_INDEX
listRoots()
array for the HKEY_LOCAL_MACHINE registry key.public static final int HKEY_USERS_INDEX
listRoots()
array for the HKEY_USERS registry key.public static final int HKEY_PERFORMANCE_DATA_INDEX
listRoots()
array for the HKEY_PERFORMANCE_DATA registry key.public static final int HKEY_CURRENT_CONFIG_INDEX
listRoots()
array for the HKEY_CURRENT_CONFIG registry key.public static final int HKEY_DYN_DATA_INDEX
listRoots()
array for the HKEY_DYN_DATA registry key.public static final String OLD_COPY_TREE
public static final String OLD_DELETE_TREE
public RegistryKey(String subKey)
RegistryKey
rooted at HKEY_CURRENT_USER
which goes all the way to subKey
.
subKey
does not have to exist in the registry.subKey
- The subkey under HKEY_CURRENT_USER.IllegalArgumentException
- if subKey
is null
.RegistryKey(String, boolean)
,
RegistryKey(String, boolean, boolean)
,
RegistryKey(String, boolean, String)
,
RegistryKey(String, boolean, String, boolean)
public RegistryKey(String subKey, boolean create)
RegistryKey
rooted at HKEY_CURRENT_USER
which goes all the way to subKey
.
subKey
does not have to exist in the registry.
subKey
- The subkey under HKEY_CURRENT_USER.create
- If true
, will create the specified key now.IllegalArgumentException
- if subKey
is null
.RegistryException
- if the key could not be created.RegistryKey(String)
,
RegistryKey(String, boolean, boolean)
,
RegistryKey(String, boolean, String)
,
RegistryKey(String, boolean, String, boolean)
public RegistryKey(String subKey, boolean create, boolean nonVolatile)
RegistryKey
rooted at HKEY_CURRENT_USER
which goes all the way to subKey
.
subKey
does not have to exist in the registry.
subKey
- The subkey under HKEY_CURRENT_USER.create
- If true
, will create the specified key now.nonVolatile
- true
if the subKey should persist, false
otherwise.IllegalArgumentException
- if subKey
is null
.RegistryException
- if the key could not be created.RegistryKey(String)
,
RegistryKey(String, boolean)
,
RegistryKey(String, boolean, String)
,
RegistryKey(String, boolean, String, boolean)
public RegistryKey(String subKey, boolean create, String clazz)
RegistryKey
rooted at HKEY_CURRENT_USER
which goes all the way to subKey
with a specific class name.
subKey
does not have to exist in the registry.
subKey
- The subkey under HKEY_CURRENT_USER.create
- If true
, will create the specified key now.clazz
- The user-defined class name for subKey
.IllegalArgumentException
- if subKey
is null
.RegistryException
- if the key could not be created.RegistryKey(String)
,
RegistryKey(String, boolean)
,
RegistryKey(String, boolean, boolean)
,
RegistryKey(String, boolean, String, boolean)
public RegistryKey(String subKey, boolean create, String clazz, boolean nonVolatile)
RegistryKey
rooted at HKEY_CURRENT_USER
which goes all the way to subKey
with a specific class name.
subKey
does not have to exist in the registry.
subKey
- The subkey under HKEY_CURRENT_USER.create
- If true
, will create the specified key now.clazz
- The user-defined class name for subKey
.nonVolatile
- true
if subKey
should persist, false
otherwise.IllegalArgumentException
- if subKey
is null
.RegistryException
- if the key could not be created.RegistryKey(String)
,
RegistryKey(String, boolean)
,
RegistryKey(String, boolean, boolean)
,
RegistryKey(String, boolean, String)
public RegistryKey(RegistryKey root, String subKey)
RegistryKey
rooted at root
which goes all the way to subKey
.
root
and subKey
does not have to exist in the registry.root
- The root of the registry subtree.subKey
- The subkey under root
.IllegalArgumentException
- if root
or subKey
is null
.RegistryKey(RegistryKey, String, boolean)
,
RegistryKey(RegistryKey, String, boolean, boolean)
,
RegistryKey(RegistryKey, String, boolean, String)
,
RegistryKey(RegistryKey, String, boolean, String, boolean)
public RegistryKey(RegistryKey root, String subKey, boolean create)
RegistryKey
rooted at root
which goes all the way to subKey
.
root
and subKey
does not have to exist in the registry.
root
- The root of the registry subtree.subKey
- The subkey under root
.create
- If true
, will create the specified key now.IllegalArgumentException
- if root
or subKey
is null
.RegistryException
- if the key could not be created.RegistryKey(RegistryKey, String)
,
RegistryKey(RegistryKey, String, boolean, boolean)
,
RegistryKey(RegistryKey, String, boolean, String)
,
RegistryKey(RegistryKey, String, boolean, String, boolean)
public RegistryKey(RegistryKey root, String subKey, boolean create, boolean nonVolatile)
RegistryKey
rooted at root
which goes all the way to subKey
.
root
and subKey
does not have to exist in the registry.
root
- The root of the registry subtree.subKey
- The subkey under root
.create
- If true
, will create the specified key now.nonVolatile
- true
if the subKey
should persist, false
otherwise.IllegalArgumentException
- if root
or subKey
is null
.RegistryException
- if the key could not be created.RegistryKey(RegistryKey, String)
,
RegistryKey(RegistryKey, String, boolean)
,
RegistryKey(RegistryKey, String, boolean, String)
,
RegistryKey(RegistryKey, String, boolean, String, boolean)
public RegistryKey(RegistryKey root, String subKey, boolean create, String clazz)
RegistryKey
rooted at root
which goes all the way to subKey
with a specific class name.
root
and subKey
does not have to exist in the registry.
root
- The root of the registry subtree.subKey
- The subkey under root
.create
- If true
, will create the specified key now.clazz
- The user-defined class name for subKey
.IllegalArgumentException
- if root
or subKey
is null
.RegistryException
- if the key could not be created.RegistryKey(RegistryKey, String)
,
RegistryKey(RegistryKey, String, boolean)
,
RegistryKey(RegistryKey, String, boolean, boolean)
,
RegistryKey(RegistryKey, String, boolean, String, boolean)
public RegistryKey(RegistryKey root, String subKey, boolean create, String clazz, boolean nonVolatile)
RegistryKey
rooted at root
which goes all the way to subKey
with a specific class name.
root
and subKey
does not have to exist in the registry.
root
- The root of the registry subtree.subKey
- The subkey under root
.create
- If true
will create the specified key now.clazz
- The user-defined class name for subKey
.nonVolatile
- true
if subKey
should persist, false
otherwise.IllegalArgumentException
- if root
or subKey
is null
.RegistryException
- if the key could not be created.RegistryKey(RegistryKey, String)
,
RegistryKey(RegistryKey, String, boolean)
,
RegistryKey(RegistryKey, String, boolean, boolean)
,
RegistryKey(RegistryKey, String, boolean, String)
public static void autoExpandEnvironmentVariables(boolean auto)
getValue(String)
or getValues()
.
auto
- true
if REG_EXPAND_SZ value data should be expanded,
false
otherwise.public static RegistryKey connect(String machine, RegistryKey root)
machine
. The remote computer
must have the Remote Registry Service started, otherwise a connection won't be established to the
remote computer's registry. If machine
is null
or has a length of 0,
then this method connects to the local machine.
root
must represent either HKEY_LOCAL_MACHINE, HKEY_USERS, or
HKEY_PERFORMANCE_DATA.machine
- The name of the remote computer to connect to. Must be in the form: \\computername.root
- The root key of the remote registry to connect to. Must be either HKEY_LOCAL_MACHINE,
HKEY_USERS, or HKEY_PERFORMANCE_DATA.RegistryKey
object which represents the specified root key on a remote computer.IllegalArgumentException
- if root is null
.RegistryException
- if root
is not an allowed root key.public static int deleteKeys(RegistryKey... keys)
keys
represents a symbolic link,
then use the deleteLink()
method on the element instead.keys
- The set of registry keys to delete.formatErrorMessage(int)
.deleteLinks(RegistryKey...)
public static int deleteLinks(RegistryKey... keys)
keys
- The set of symbolic link registry keys to delete.formatErrorMessage(int)
.deleteKeys(RegistryKey...)
public static String expandEnvironmentVariables(String envStr)
envStr
- The String
containing the environment variable to expand.envStr
.public static String formatErrorMessage(int code)
RegistryKey
class or one of the
RegistryValue
classes.code
- The error code returned from a method.public static RegistryQuota getRegistryQuota()
RegistryQuota
object that contains the registry size values
or null
if the function is not supported on the current Windows
system.public static RegistryKey getRootKeyForIndex(int index)
index
- The index of the root key to retrieve, corresponds to the HKEY_*_INDEX values.RegistryKey
which is associated with the specified index.ArrayIndexOutOfBoundsException
- if index
is negative or greater than the number of
root keys.public static boolean isAutoExpandEnvironmentVariables()
getValue(String)
or getValues()
.
true
if REG_EXPAND_SZ value data should be expanded,
false
otherwise.public static RegistryKey[] listRoots()
public static RegistryKey parseKey(String key)
String
path of a registry key into
a RegistryKey
object. The path must point
to a key that currently exists in the registry.key
- The path to a registry key.RegistryKey
object represented by the path
or null
if the key does not exist.parseKey(String, boolean)
,
parseKey(String, boolean, boolean)
public static RegistryKey parseKey(String key, boolean create)
String
path of a registry key into
a RegistryKey
object. The boolean
parameter allows the returned key to be created if it doesn't exist.key
- The path to a registry key.create
- If true
creates the returned key.RegistryKey
object represented by the path
or null
if the key could not be created.parseKey(String)
,
parseKey(String, boolean, boolean)
public static RegistryKey parseKey(String key, boolean create, boolean nonVolatile)
String
path of a registry key into
a RegistryKey
object. The first optional boolean
parameter allows the returned key to be created if it doesn't exist.
The second boolean
determines if the key should be permanent.key
- The path to a registry key.create
- If true
creates the returned key.nonVolatile
- true
if key
should persist, false
otherwise.RegistryKey
object represented by the path
or null
if the key could not be created.public boolean canDelete()
this
can be deleted.
A registry key can only be deleted if it is not a
root key and if it does not contain any subkeys.true
if the key can be deleted,
false
otherwise.deleteKey()
,
deleteSubKey(String)
,
deleteView64Key(String)
public boolean canDeleteLink()
this
can be deleted.
A registry key can only be deleted if it is not a
root key and if it does not contain any subkeys.true
if the key can be deleted,
false
otherwise.deleteLink()
public boolean canDeleteTree()
this
can be deleted.
A registry subtree can only be deleted if it is not a root key.true
if the subtree can be deleted,
false
otherwise.deleteTree()
public boolean canLoadKey()
this
can load a registry hive.
A registry key can only load a hive if it is the HKEY_LOCAL_MACHINE
or the HKEY_USERS key.true
if the key can load a registry hive,
false
otherwise.loadKey(String, File)
public boolean canRename()
this
can be renamed.
A registry key can only be renamed if it is not a root key.true
if the key can be renamed,
false
otherwise.renameKey(String)
public boolean canUnLoadKey()
this
can be unloaded from the registry.
A registry key can only be unloaded if it is the direct descendant of the
HKEY_LOCAL_MACHINE or the HKEY_USERS key.true
if the key can be unloaded from the registry,
false
otherwise.unLoadKey()
public boolean canWrite()
this
.true
if the key can have values,
false
otherwise.deleteValue(String)
,
deleteValue(RegistryValue)
,
newValue(String, ValueType)
,
renameValue(RegistryValue, String)
public Object clone()
this
.public int compareTo(RegistryKey o)
Comparable
.
Allows a list of RegistryKey
s to be sorted in ascending order.
Null
values always come before non-null
values.compareTo
in interface Comparable<RegistryKey>
o
- A RegistryKey
to compare against this
.this
should go first
if > 0, o
should go first@Deprecated public void copy(RegistryKey to)
this
to to
.
copyTree(RegistryKey)
.to
- The destination RegistryKey
for the copy
operation.public int copyTree(RegistryKey dest)
this
to dest
. This method will fail if a registry link key is encountered.
OLD_COPY_TREE
to "true".dest
- The destination RegistryKey
for the copy
operation.formatErrorMessage(int)
.copyTree(RegistryKey, boolean)
,
copySubTree(String, RegistryKey)
,
copySubTree(String, RegistryKey, boolean)
public int copyTree(RegistryKey dest, boolean copyLinks)
this
to dest
. This method will fail if a registry link key is encountered
unless copyLinks
is set to true
.
copyLinks
is true
, then this method will try to copy any link keys it
finds without using RegCopyTree because that method can't copy links. If the older implementation
is preferred, then set the system property OLD_COPY_TREE
to "true".dest
- The destination RegistryKey
for the copy
operation.copyLinks
- true
if the physical link should be copied,
false
otherwise.formatErrorMessage(int)
.copyTree(RegistryKey)
,
copySubTree(String, RegistryKey)
,
copySubTree(String, RegistryKey, boolean)
public int copySubTree(String subKey, RegistryKey dest)
subkey
to dest
. This method will fail if a registry link key is encountered.
subKey
- The subkey tree under this
to copy.dest
- The destination RegistryKey
for the copy
operation.formatErrorMessage(int)
.copyTree(RegistryKey)
,
copyTree(RegistryKey, boolean)
,
copySubTree(String, RegistryKey, boolean)
public int copySubTree(String subKey, RegistryKey dest, boolean copyLinks)
subkey
to dest
. This method will fail if a registry link key is encountered
unless copyLinks
is set to true
.
copyLinks
is true
, then this method will try to
copy any link keys it finds without using RegCopyTree because that method can't copy links.subKey
- The subkey tree under this
to copy.dest
- The destination RegistryKey
for the copy
operation.copyLinks
- true
if the physical link should be copied,
false
otherwise.formatErrorMessage(int)
.copyTree(RegistryKey)
,
copyTree(RegistryKey, boolean)
,
copySubTree(String, RegistryKey)
public int copyValue(RegistryKey dest, RegistryValue value)
value
to
the registry key dest
.value
- The registry value to copy.dest
- The registry key that value
should be copied to.formatErrorMessage(int)
.canWrite()
,
copyValues(RegistryKey, String...)
,
copyValues(RegistryKey, RegistryValue...)
public int copyValues(RegistryKey dest, String... va)
va
to
the registry key dest
.va
- The set of names of the registry values to copy.dest
- The registry key that the names in va
should be copied to.formatErrorMessage(int)
.canWrite()
,
copyValue(RegistryKey, RegistryValue)
,
copyValues(RegistryKey, RegistryValue...)
public int copyValues(RegistryKey dest, RegistryValue... va)
va
to
the registry key dest
.va
- A set of registry values to copy.dest
- The registry key that the values in va
should be copied to.formatErrorMessage(int)
.canWrite()
,
copyValue(RegistryKey, RegistryValue)
,
copyValues(RegistryKey, String...)
public int copySubKeyValue(String subKey, RegistryKey dest, RegistryValue value)
value
within subKey
to
the registry key dest
.subKey
- The subkey from which the values will be copied from.value
- The registry value to copy.dest
- The registry key that value
should be copied to.formatErrorMessage(int)
.canWrite()
,
copySubKeyValues(String, RegistryKey, String...)
,
copySubKeyValues(String, RegistryKey, RegistryValue...)
public int copySubKeyValues(String subKey, RegistryKey dest, String... va)
va
within subKey
to
the registry key dest
.subKey
- The subkey from which the values will be copied from.va
- The set of names of the registry values to copy.dest
- The registry key that the names in va
should be copied to.formatErrorMessage(int)
.canWrite()
,
copySubKeyValue(String, RegistryKey, RegistryValue)
,
copySubKeyValues(String, RegistryKey, RegistryValue...)
public int copySubKeyValues(String subKey, RegistryKey dest, RegistryValue... va)
va
within subKey
to
the registry key dest
.subKey
- The subkey from which the values will be copied from.va
- A set of registry values to copy.dest
- The registry key that the values in va
should be copied to.formatErrorMessage(int)
.canWrite()
,
copySubKeyValue(String, RegistryKey, RegistryValue)
,
copySubKeyValues(String, RegistryKey, String...)
public int create()
this
in the registry.formatErrorMessage(int)
.create(boolean)
,
create(String)
,
create(String, boolean)
public int create(boolean nonVolatile)
this
in the registry.nonVolatile
- true
if this
should persist, false
otherwise.formatErrorMessage(int)
.create()
,
create(String)
,
create(String, boolean)
public int create(String clazz)
this
in the registry with the specified class name.clazz
- The class name for this
.formatErrorMessage(int)
.create()
,
create(boolean)
,
create(String, boolean)
public int create(String clazz, boolean nonVolatile)
this
in the registry with the specified class name.clazz
- The class name for this
.nonVolatile
- true
if this
should persist, false
otherwise.formatErrorMessage(int)
.create()
,
create(boolean)
,
create(String)
public boolean created()
this
was created
or if it already existed in the registry.true
if the key was created,
false
otherwise.public int createLink(RegistryKey target)
this
in the registry as a link to another key.target
- The RegistryKey
to link to.formatErrorMessage(int)
.createLink(RegistryKey, boolean)
,
createLink(RegistryKey, String)
,
createLink(RegistryKey, String, boolean)
public int createLink(RegistryKey target, boolean nonVolatile)
this
in the registry as a link to another key.target
- The RegistryKey
to link to.nonVolatile
- true
if this
should persist, false
otherwise.formatErrorMessage(int)
.createLink(RegistryKey)
,
createLink(RegistryKey, String)
,
createLink(RegistryKey, String, boolean)
public int createLink(RegistryKey target, String clazz)
this
in the registry with the specified class name
as a link to another key.target
- The RegistryKey
to link to.clazz
- The class name for this
.formatErrorMessage(int)
.createLink(RegistryKey)
,
createLink(RegistryKey, boolean)
,
createLink(RegistryKey, String, boolean)
public int createLink(RegistryKey target, String clazz, boolean nonVolatile)
this
in the registry with the specified class name
as a link to another key.target
- The RegistryKey
to link to.clazz
- The class name for this
.nonVolatile
- true
if this
should persist, false
otherwise.formatErrorMessage(int)
.createLink(RegistryKey)
,
createLink(RegistryKey, boolean)
,
createLink(RegistryKey, String)
public RegistryKey createSubKey(String subKey)
this
.
If the key could not be created, then null
is returned.subKey
- The subkey under this
to create.RegistryKey
representing subKey
or null
if the key could not be created.createSubKey(String, boolean)
,
createSubKey(String, String)
,
createSubKey(String, String, boolean)
public RegistryKey createSubKey(String subKey, boolean nonVolatile)
this
.
If the key could not be created, then null
is returned.subKey
- The subkey under this
to create.nonVolatile
- true
if subKey
should persist, false
otherwise.RegistryKey
representing subKey
or null
if the key could not be created.createSubKey(String)
,
createSubKey(String, String)
,
createSubKey(String, String, boolean)
public RegistryKey createSubKey(String subKey, String clazz)
this
with the specified class name.
If the key could not be created, then null
is returned.subKey
- The subkey under this
to create.clazz
- The class name for this
.RegistryKey
representing subKey
or null
if the key could not be created.createSubKey(String)
,
createSubKey(String, boolean)
,
createSubKey(String, String, boolean)
public RegistryKey createSubKey(String subKey, String clazz, boolean nonVolatile)
this
with the specified class name.
If the key could not be created, then null
is returned.subKey
- The subkey under this
to create.clazz
- The class name for this
.nonVolatile
- true
if subKey
should persist, false
otherwise.RegistryKey
representing subKey
or null
if the key could not be created.createSubKey(String)
,
createSubKey(String, boolean)
,
createSubKey(String, String)
public RegistryKey createSubKeyLink(String subKey, RegistryKey target)
this
which will link to another key.
If the key could not be created, then null
is returned.subKey
- The subkey under this
to create.target
- The RegistryKey
to link to.RegistryKey
representing subkey
or null
if the key could not be created.createSubKeyLink(String, RegistryKey, boolean)
,
createSubKeyLink(String, RegistryKey, String)
,
createSubKeyLink(String, RegistryKey, String, boolean)
public RegistryKey createSubKeyLink(String subKey, RegistryKey target, boolean nonVolatile)
this
which will link to another key.
If the key could not be created, then null
is returned.subKey
- The subkey under this
to create.target
- The RegistryKey
to link to.nonVolatile
- true
if subKey
should persist, false
otherwise.RegistryKey
representing subKey
or null
if the key could not be created.createSubKeyLink(String, RegistryKey)
,
createSubKeyLink(String, RegistryKey, String)
,
createSubKeyLink(String, RegistryKey, String, boolean)
public RegistryKey createSubKeyLink(String subKey, RegistryKey target, String clazz)
this
with the specified class name
as a link to another key.
If the key could not be created, then null
is returned.subKey
- The subkey under this
to create.target
- The RegistryKey
to link to.clazz
- The class name for this
.RegistryKey
representing subKey
or null
if the key could not be created.createSubKeyLink(String, RegistryKey)
,
createSubKeyLink(String, RegistryKey, boolean)
,
createSubKeyLink(String, RegistryKey, String, boolean)
public RegistryKey createSubKeyLink(String subKey, RegistryKey target, String clazz, boolean nonVolatile)
this
with the specified class name
as a link to another key.
If the key could not be created, then null
is returned.subKey
- The subkey under this
to create.target
- The RegistryKey
to link to.clazz
- The class name for this
.nonVolatile
- true
if subKey
should persist, false
otherwise.RegistryKey
representing subKey
or null
if the key could not be created.createSubKeyLink(String, RegistryKey)
,
createSubKeyLink(String, RegistryKey, boolean)
,
createSubKeyLink(String, RegistryKey, String)
public int deleteKey()
this
from the registry.
this
represents a symbolic link, then use the deleteLink()
method instead.formatErrorMessage(int)
.canDelete()
,
deleteSubKey(String)
,
deleteSubKeys(String...)
,
deleteView64Key(String)
,
deleteView64Keys(String...)
public int deleteLink()
this
symbolic link from the registry.formatErrorMessage(int)
.canDeleteLink()
public int deleteSubKey(String subKey)
subKey
from this
.
subKey
represents a symbolic link,
then use the deleteLink()
method on the subkey instead.subKey
- The subkey under this
to delete.formatErrorMessage(int)
.canDelete()
,
deleteKey()
,
deleteSubKeys(String...)
,
deleteView64Key(String)
,
deleteView64Keys(String...)
public int deleteSubKeys(String... subKeys)
subKey
s from this
.
subKey
s represents a symbolic link,
then use the deleteLink()
method on the subkey instead.subKeys
- The subkeys under this
to delete.formatErrorMessage(int)
.canDelete()
,
deleteKey()
,
deleteSubKey(String)
,
deleteView64Key(String)
,
deleteView64Keys(String...)
public int deleteView64Key(String subKey)
subKey
from a 64-bit specific view of the registry from this
if isViewing64BitRegistry()
is true
. Otherwise subKey
is deleted
from the 32-bit specific view of the registry.
subKey
represents a symbolic link,
then use the deleteLink()
method on the subkey instead.subKey
- The subkey under this
to delete.formatErrorMessage(int)
.canDelete()
,
deleteKey()
,
deleteSubKey(String)
,
deleteSubKeys(String...)
,
deleteView64Keys(String...)
,
isViewing64BitRegistry()
,
view64BitRegistry(boolean)
public int deleteView64Keys(String... subKeys)
subKey
s from a 64-bit specific view of the registry from this
if isViewing64BitRegistry()
is true
. Otherwise the subKey
s are deleted
from the 32-bit specific view of the registry.
subKey
s represents a symbolic link,
then use the deleteLink()
method on the subkey instead.subKeys
- The subkeys under this
to delete.formatErrorMessage(int)
.canDelete()
,
deleteKey()
,
deleteSubKey(String)
,
deleteSubKeys(String...)
,
deleteView64Key(String)
,
isViewing64BitRegistry()
,
view64BitRegistry(boolean)
public int deleteTree()
this
from the registry.
this
represents a symbolic link, then use the deleteLink()
method instead.
this
key will be deleted, not this
. If the older implementation is
preferred, then set the system property OLD_DELETE_TREE
to "true".formatErrorMessage(int)
.canDeleteTree()
,
deleteTree(boolean)
,
deleteSubTree(String)
,
deleteSubTree(String, boolean)
public int deleteTree(boolean delLinks)
this
from the registry.
this
represents a symbolic link, then use the deleteLink()
method instead.
this
key will be deleted, not this
. If delLinks
is true
, then this method will try to delete any link keys it finds without using
RegDeleteTree because that method can't delete links. If the older implementation is
preferred, then set the system property OLD_DELETE_TREE
to "true".delLinks
- true
if link keys should be deleted,
false
otherwise.formatErrorMessage(int)
.canDeleteTree()
,
deleteTree()
,
deleteSubTree(String)
,
deleteSubTree(String, boolean)
public int deleteSubTree(String subKey)
subKey
from the registry.subKey
represents a symbolic link,
then use the deleteLink()
method on the subkey instead.subKey
- The subkey tree under this
to delete.formatErrorMessage(int)
.canDeleteTree()
,
deleteTree()
,
deleteTree(boolean)
,
deleteSubTree(String, boolean)
public int deleteSubTree(String subKey, boolean delLinks)
subKey
from the registry.delLinks
is true
, then this method will try to delete any
link keys it finds without using RegDeleteTree because that method can't delete links.
subKey
represents a symbolic link,
then use the deleteLink()
method on the subkey instead.subKey
- The subkey tree under this
to delete.delLinks
- true
if link keys should be deleted,
false
otherwise.formatErrorMessage(int)
.canDeleteTree()
,
deleteTree()
,
deleteTree(boolean)
,
deleteSubTree(String)
public int deleteValue(String value)
this
.value
- The name of the value to delete.formatErrorMessage(int)
.canWrite()
,
deleteValue(RegistryValue)
,
deleteValues(String...)
,
deleteValues(RegistryValue...)
,
deleteSubKeyValue(String, String)
,
deleteSubKeyValue(String, RegistryValue)
,
deleteSubKeyValues(String, String...)
,
deleteSubKeyValues(String, RegistryValue...)
public int deleteValue(RegistryValue value)
value
from this
.value
- The RegistryValue
to delete.formatErrorMessage(int)
.canWrite()
,
deleteValue(String)
,
deleteValues(String...)
,
deleteValues(RegistryValue...)
,
deleteSubKeyValue(String, String)
,
deleteSubKeyValue(String, RegistryValue)
,
deleteSubKeyValues(String, String...)
,
deleteSubKeyValues(String, RegistryValue...)
public int deleteValues(String... va)
va
from this
.va
- The set of names of the values to delete.formatErrorMessage(int)
.canWrite()
,
deleteValue(String)
,
deleteValue(RegistryValue)
,
deleteValues(RegistryValue...)
,
deleteSubKeyValue(String, String)
,
deleteSubKeyValue(String, RegistryValue)
,
deleteSubKeyValues(String, String...)
,
deleteSubKeyValues(String, RegistryValue...)
public int deleteValues(RegistryValue... va)
RegistryValues
within va
from this
.va
- The set of RegistryValue
s to delete.formatErrorMessage(int)
.canWrite()
,
deleteValue(String)
,
deleteValue(RegistryValue)
,
deleteValues(String...)
,
deleteSubKeyValue(String, String)
,
deleteSubKeyValue(String, RegistryValue)
,
deleteSubKeyValues(String, String...)
,
deleteSubKeyValues(String, RegistryValue...)
public int deleteSubKeyValue(String subKey, String value)
subKey
. If subKey
is null
or has a length of 0, then this behaves exactly as deleteValue(String)
.subKey
- The subKey from which to delete the value.value
- The name of the value to delete.formatErrorMessage(int)
.canWrite()
,
deleteValue(String)
,
deleteValue(RegistryValue)
,
deleteValues(String...)
,
deleteValues(RegistryValue...)
,
deleteSubKeyValue(String, RegistryValue)
,
deleteSubKeyValues(String, String...)
,
deleteSubKeyValues(String, RegistryValue...)
public int deleteSubKeyValue(String subKey, RegistryValue value)
value
from subKey
. If subKey
is null
or has a length of 0, then this behaves exactly as deleteValue(RegistryValue)
.subKey
- The subKey from which to delete the value.value
- The RegistryValue
to delete.formatErrorMessage(int)
.canWrite()
,
deleteValue(String)
,
deleteValue(RegistryValue)
,
deleteValues(String...)
,
deleteValues(RegistryValue...)
,
deleteSubKeyValue(String, String)
,
deleteSubKeyValues(String, String...)
,
deleteSubKeyValues(String, RegistryValue...)
public int deleteSubKeyValues(String subKey, String... va)
va
from subKey
. If subKey
is null
or has a length of 0, then this behaves exactly as deleteValues(String...)
.subKey
- The subKey from which to delete the values.va
- The set of names of the values to delete.formatErrorMessage(int)
.canWrite()
,
deleteValue(String)
,
deleteValue(RegistryValue)
,
deleteValues(String...)
,
deleteValues(RegistryValue...)
,
deleteSubKeyValue(String, String)
,
deleteSubKeyValue(String, RegistryValue)
,
deleteSubKeyValues(String, RegistryValue...)
public int deleteSubKeyValues(String subKey, RegistryValue... va)
va
from subKey
. If subKey
is null
or has a length of 0, then this behaves exactly as deleteValues(RegistryValue...)
.subKey
- The subKey from which to delete the values.va
- The set of RegistryValue
s to delete.formatErrorMessage(int)
.canWrite()
,
deleteValue(String)
,
deleteValue(RegistryValue)
,
deleteValues(String...)
,
deleteValues(RegistryValue...)
,
deleteSubKeyValue(String, String)
,
deleteSubKeyValue(String, RegistryValue)
,
deleteSubKeyValues(String, String...)
public int disableReflection()
this
key.
formatErrorMessage(int)
.disableReflectionTree()
public int disableReflectionTree()
this
key and its entire subtree.
formatErrorMessage(int)
.disableReflection()
public int enableReflection()
this
key.
formatErrorMessage(int)
.enableReflectionTree()
public int enableReflectionTree()
this
key and its entire subtree.
formatErrorMessage(int)
.enableReflection()
public boolean equals(Object o)
public boolean exists()
this
exists in the registry.true
if this
exists,
false
otherwise.public int flushKey()
this
into the registry.
flushKey
is an expensive operation that will
signficantly affect performance because it blocks modifications to
this
until the flush operation completes.formatErrorMessage(int)
.public String getClassName()
this
if it is set.this
if set or null
otherwise.public static String getCurrentUserSid()
String
format.String
representation of the current user's SID.public int getIndex()
this
under the parent.
The index is zero based.this
or Integer.MIN_VALUE if this
is a root key or if this
no longer exists.public int[] getKeyInfo()
this
.
The information includes:
this
this
this
this
or null
if an error occurred.public int getLastError()
this
.public int getLevel()
this
resides in.this
.public RegistryKey getLinkLocation()
this
if it is a link.public String getName()
this
key.this
.public int getNumberOfSubKeys()
this
.this
.public int getNumberOfValues()
this
.this
.public RegistryKey getParent()
RegistryKey
of this
.
If this
refers to a root key, then null
is returned.this
or null
if this
is a root.public String getPath()
this
.this
.public int getRootIndex()
this
in the listRoots()
array.listRoots()
array of this
.public RegistryKey getRootKey()
this
.
A root key is similar to HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE.this
.public RegistryKey getSubKey(String name)
RegistryKey
which represents the subkey
with a name of name
under this
.
If the key doesn't exist, then null
is returned.name
- The name of the subkey to get.RegistryKey
which is a subkey of this
with name name
or null
if the key doesn't exist.getSubKeyNames()
,
getSubKeys()
,
subKeysIterator()
,
subKeyNamesIterator()
public String[] getSubKeyNames()
String
s which
are the names of the subkeys under this
.
The method returns null
when an error occurs.this
or null
if an error occured.getSubKey(String)
,
getSubKeys()
,
getSubKeys(String...)
,
subKeysIterator()
,
subKeyNamesIterator()
public List<RegistryKey> getSubKeys()
RegistryKey
s which represent the subkeys
that are under this
. The list is unsorted.
The method returns null
when an error occurs.RegistryKey
s that are
the subkeys of this
or null
if an error occured.getSubKey(String)
,
getSubKeyNames()
,
getSubKeys(String...)
,
subKeysIterator()
,
subKeyNamesIterator()
public List<RegistryKey> getSubKeys(String... subKeys)
RegistryKey
s which are specified by the names in subKeys
that are under this
.
The method returns null
when an error occurs.subKeys
- The names of the subkeys to retrieve.RegistryKey
s that are
the subkeys of this
named by subKeys
or null
if an error occured.getSubKey(String)
,
getSubKeyNames()
,
getSubKeys()
,
subKeysIterator()
,
subKeyNamesIterator()
public SystemTime getSystemTime()
this
as
a SystemTime
object.this
as a SystemTime
object.SystemTime
public RegistryValue getValue(String name)
RegistryValue
which represents the
value with a name of name
under
this
.
null
is returned.name
- The name of the value to obtain.RegistryValue
which represents the value
named by name
or null
if the value
doesn't exist.getValueNames()
,
getValues()
,
getValues(String...)
,
valuesIterator()
,
valueNamesIterator()
public String[] getValueNames()
String
s which
are the names of the values under this
.
The method returns null
when an error occurs.null
if an error occured.getValue(String)
,
getValues()
,
getValues(String...)
,
valuesIterator()
,
valueNamesIterator()
public List<RegistryValue> getValues()
RegistryValue
s which represent the values
that are under this
. The list is unsorted.
The method returns null
when an error occurs.RegistryValue
s that are
the values of this key or null
if an error occured.getValue(String)
,
getValueNames()
,
getValues(String...)
,
valuesIterator()
,
valueNamesIterator()
public List<RegistryValue> getValues(String... va)
RegistryValue
s which represent the values
that are named by va
.
The method returns null
if an error occurs.va
- The names of the values to retrieve.RegistryValue
s that are named by va
under this
or null
if an error occurs.getValue(String)
,
getValueNames()
,
getValues()
,
valuesIterator()
,
valueNamesIterator()
public static ValueType getValueType(int type)
ValueType
object based
on the integer type that is passed in. If type
is not a legal
registry value type, then null
is returned.type
- An integer representing a value type.ValueType
object based on the integer type
or null
if type
is not a legal registry value type.public boolean hasDefaultValue()
this
contains the default or unnamed value.true
if the default value exists,
false
otherwise.public int hashCode()
this
.public boolean hasSubKeys()
this
contains any subkeys.true
if subkeys exist,
false
otherwise.public boolean hasValues()
this
contains any values.true
if values exist,
false
otherwise.public boolean isLinkKey()
this
key is a symbolic link
to another key.true
if the key is a link, or false
otherwise.public boolean isRemoteRegistryKey()
this
key is a remote registry key.true
if the key is a remote registry key, or false
otherwise.public boolean isViewing64BitRegistry()
true
if the 64-bit registry is being viewed,
false
otherwise.public boolean keyExists(String subKey)
this
.subKey
- The subkey whose existence will be tested.true
if subKey
exists,
false
otherwise.public boolean keyIsLink(String subKey)
this
is a link.subKey
- The subkey whose existence will be tested.true
if subKey
exists,
false
otherwise.public long lastModified()
this
was last modified.long
value representing the time the key was last modified,
measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970),
or 0L if the key does not exist.public int loadKey(String subKey, File regFile)
subKey
- The subkey to create.regFile
- The registry hive that contains the information to load.formatErrorMessage(int)
.canLoadKey()
public RegistryValue newValue(String name, ValueType type)
this
with the specified
name and type. The newly created value is then returned. If the
value name already exists in the registry, then null
is returned.name
- The name of the value to create.type
- The type of the value.null
if it already exists or an error occurred.canWrite()
public RegistryValue newValue(String name, int type)
this
with the specified
name and type. The newly created value is then returned. If the
value name already exists in the registry, then null
is returned.name
- The name of the value to create.type
- The type of the value.null
if it already exists or an error occurred.canWrite()
public boolean queryReflection()
this
key is turned off.
true
if reflection is disabled, false
otherwisepublic boolean renameKey(String newKeyName)
this
to newKeyName
.true
if the rename completed successfully,
false
otherwise.canRename()
public boolean renameValue(String old, String newValueName)
old
to newValueName
.old
- The name of the current value to rename.newValueName
- The new name of the value.true
if the rename completed successfully,
false
otherwise.canWrite()
,
renameValue(RegistryValue, String)
public boolean renameValue(RegistryValue old, String newValueName)
old
to newValueName
.old
- The current value to rename.newValueName
- The new name of the value.true
if the rename completed successfully,
false
otherwise.canWrite()
,
renameValue(String, String)
public int replaceKey(File newRegFile, File oldRegFile)
this
key and all the subkeys with another file,
so that when the system is next started, the key and subkeys will have the values
stored in the new file.newRegFile
- The file containing the new information for the key.oldRegFile
- The file that will be receive a backup of the information being replaced.formatErrorMessage(int)
.public int replaceSubKey(String subKey, File newRegFile, File oldRegFile)
this
key and all its subkeys with another file,
so that when the system is next started, the key and subkeys will have the values
stored in the new file.subKey
- The subkey under this
key.newRegFile
- The file containing the new information for the key.oldRegFile
- The file that will be receive a backup of the information being replaced.formatErrorMessage(int)
.public int restoreKey(File regFile)
this
key. This registry information may be in the
form of a key and multiple levels of subkeys.regFile
- The file containing the registry information to restore.formatErrorMessage(int)
.public int restoreKey(File regFile, boolean force)
this
key. This registry information may be in the
form of a key and multiple levels of subkeys.regFile
- The file containing the registry information to restore.force
- Force the restore operation to execute even if this
key
or subkeys of this
have open handles.formatErrorMessage(int)
.public int saveKey(File regFile) throws IOException
this
and all subkeys and values to a new file, in the standard format.regFile
- The file to save to.formatErrorMessage(int)
.IOException
- If regFile
already exists and a temporary file
could not be created.saveKey(boolean, boolean, File)
public int saveKey(boolean latest, boolean noCompress, File regFile) throws IOException
this
and all subkeys and values to a new file, in the specified format.
The standard format is the only format supported by Windows 2000. The latest format works for
Windows XP and higher.
If noCompress
is true
, then this
should be a root
hive under HKEY_LOCAL_MACHINE or HKEY_USERS. For example,
HKEY_LOCAL_MACHINE\SOFTWARE is the root of a hive.
saveKey(File)
.latest
- true
if the hive should be saved using the lastest format,
false
otherwise.noCompress
- true
if the hive should not be saved with compression,
false
otherwise.regFile
- The file to save to.formatErrorMessage(int)
.IOException
- If regFile
already exists and a temporary file
could not be created.saveKey(File)
public int searchIntegerValue(int startIndex, long value)
this
key's integer values (REG_DWORD and REG_QWORD, etc.)
to be searched for a particular value. The index, if not -1, corresponds to the
index of the value in a sorted list.startIndex
- The index for the value to start with.value
- The integer key to search for.public int searchStringValue(int startIndex, String key)
this
key's string values (REG_SZ, REG_EXPAND_SZ and REG_MULTI_SZ)
to be searched for a particular value. This method is just a wrapper that searches the
values starting at the specified value index. It tests the value names as well as the
data for any part that matches the passed in key to search for. The index, if not -1,
corresponds to the index of the value in a sorted list.startIndex
- The index for the value to start with.key
- The string key to search for.public int searchStringValue(int startIndex, boolean valueName, boolean data, boolean matchStr, String key)
this
key's string values (REG_SZ, REG_EXPAND_SZ and REG_MULTI_SZ)
to be searched for a particular value. The parameters for this method allow for the
value name as well as the value's data to be searched. Also if matchStr
is true
,
then the entire value name or data must match the passed in search key. The index, if not -1,
corresponds to the index of the value in a sorted list.startIndex
- The index for the value to start with.valueName
- true
if the names of the values should be searched.data
- true
if the data of the values should be searched.matchStr
- true
if match should be constrained to the entire name or data,
false
if only a portion of the name or data contains the search key.key
- The string key to search for.public int searchBinaryValue(int startIndex, byte[] value)
this
key's binary values (REG_NONE, REG_BINARY, etc.)
to be searched for a particular value. The index, if not -1, corresponds to the
index of the value in a sorted list.startIndex
- The index for the value to start with.value
- The binary key to search for.public boolean setLinkTo(RegistryKey target)
this
represents a symbolic link, then the target for this
will be changed to the key represented by target
.target
- The RegistryKey
to link to.true
if the link was changed, false
otherwise.public Iterator<String> subKeyNamesIterator()
Iterator
of String
s which represent the names of the subkeys
that are under this
. If the subkeys of this
are
changed from outside the iterator while an iteration is in progress, then a ConcurrentModificationException
is thrown. If an error occurs, then null
is returned.Iterator
of String
s that are
the names of the subkeys of this
or null
if an error occurs.getSubKey(String)
,
getSubKeyNames()
,
getSubKeys()
,
getSubKeys(String...)
,
subKeysIterator()
public Iterator<RegistryKey> subKeysIterator()
Iterator
of RegistryKey
s which represent the subkeys
that are under this
. If the subkeys of this
are
changed from outside the iterator while an iteration is in progress, then a ConcurrentModificationException
is thrown. If an error occurs, then null
is returned.Iterator
of RegistryKey
s that are
the subkeys of this
or null
if an error occurs.getSubKey(String)
,
getSubKeyNames()
,
getSubKeys()
,
getSubKeys(String...)
,
subKeyNamesIterator()
public String toNativePath()
String
representation of this
using the native registry api format.String
representation for this
in native format.public int unLoadKey()
this
and all subkeys and values from the registry.formatErrorMessage(int)
.canUnLoadKey()
public boolean valueExists(String value)
this
.value
- The name of the value whose existence will be tested.true
if the value exists,
false
otherwise.public Iterator<String> valueNamesIterator()
Iterator
of String
s which represent the names of the values
that are under this
. If the values of this
are
changed from outside the iterator while an iteration is in progress, then a ConcurrentModificationException
is thrown. If an error occurs, then null
is returned.Iterator
of String
s that are
the names of the values of this
or null
if an error occurs.getValue(String)
,
getValueNames()
,
getValues()
,
getValues(String...)
,
valuesIterator()
public Iterator<RegistryValue> valuesIterator()
Iterator
of RegistryValue
s which represent the values
that are under this
. If the values of this
are
changed from outside the iterator while an iteration is in progress, then a ConcurrentModificationException
is thrown. If an error occurs, then null
is returned.Iterator
of RegistryValue
s that are
the values of this
or null
if an error occurs.getValue(String)
,
getValueNames()
,
getValues()
,
getValues(String...)
,
valueNamesIterator()
public void view64BitRegistry(boolean view64)
view64
- true
if the key should view the 64-bit part of the registry,
false
otherwise.Copyright © 2011, Yinon Michaeli. All rights reserved.