public class WinRegistry
extends java.lang.Object
If RegistryRoot.HKEY_CURRENT_USER is specified, the correct result for the original user is returned even if executed in the elevated helper.
Modifier and Type | Class and Description |
---|---|
static class |
WinRegistry.ExpandString
Class to represent Strings with type REG_EXPAND_SZ.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
createKey(RegistryRoot root,
java.lang.String keyName)
Creates a registry key.
|
static boolean |
createKey(RegistryRoot root,
java.lang.String keyName,
RegistryView registryView)
Creates a registry key.
|
static void |
deleteKey(RegistryRoot root,
java.lang.String keyName,
boolean onlyIfEmpty)
Deletes a registry key.
|
static void |
deleteKey(RegistryRoot root,
java.lang.String keyName,
boolean onlyIfEmpty,
RegistryView registryView)
Deletes a registry key.
|
static void |
deleteValue(RegistryRoot root,
java.lang.String keyName,
java.lang.String valueName)
Deletes a registry value.
|
static void |
deleteValue(RegistryRoot root,
java.lang.String keyName,
java.lang.String valueName,
RegistryView registryView)
Deletes a registry value.
|
static java.lang.String[] |
getSubKeyNames(RegistryRoot root,
java.lang.String keyName)
Retrieves the sub keys of a registry key.
|
static java.lang.String[] |
getSubKeyNames(RegistryRoot root,
java.lang.String keyName,
RegistryView registryView)
Retrieves the sub keys of a registry key.
|
static java.lang.Object |
getValue(RegistryRoot root,
java.lang.String keyName,
java.lang.String valueName)
Retrieves a registry value.
|
static java.lang.Object |
getValue(RegistryRoot root,
java.lang.String keyName,
java.lang.String valueName,
RegistryView registryView)
Retrieves a registry value.
|
static java.lang.String[] |
getValueNames(RegistryRoot root,
java.lang.String keyName)
Retrieves the exiting value names of a registry key.
|
static java.lang.String[] |
getValueNames(RegistryRoot root,
java.lang.String keyName,
RegistryView registryView)
Retrieves the exiting value names of a registry key.
|
static boolean |
keyExists(RegistryRoot root,
java.lang.String keyName)
Checks if a registry key exists.
|
static boolean |
keyExists(RegistryRoot root,
java.lang.String keyName,
RegistryView registryView)
Checks if a registry key exists.
|
static boolean |
restoreKey(RegistryRoot root,
java.lang.String keyName,
java.lang.String fileName)
Restore a sub-tree of the registry from a file.
|
static boolean |
restoreKey(RegistryRoot root,
java.lang.String keyName,
java.lang.String fileName,
RegistryView registryView)
Restore a sub-tree of the registry from a file.
|
static boolean |
saveKey(RegistryRoot root,
java.lang.String keyName,
java.lang.String fileName)
Save a sub-tree of the registry to a file.
|
static boolean |
saveKey(RegistryRoot root,
java.lang.String keyName,
java.lang.String fileName,
RegistryView registryView)
Save a sub-tree of the registry to a file.
|
static boolean |
setValue(RegistryRoot root,
java.lang.String keyName,
java.lang.String valueName,
java.lang.Object value)
Sets a registry value.
|
static boolean |
setValue(RegistryRoot root,
java.lang.String keyName,
java.lang.String valueName,
java.lang.Object value,
RegistryView registryView)
Sets a registry value.
|
public static boolean keyExists(RegistryRoot root, java.lang.String keyName)
root
- one of the RegistryRoot.* constants.keyName
- the name of the key without a leading backslash.public static boolean createKey(RegistryRoot root, java.lang.String keyName)
root
- one of the RegistryRoot.* constants.keyName
- the name of the key without a leading backslash.public static java.lang.Object getValue(RegistryRoot root, java.lang.String keyName, java.lang.String valueName)
root
- one of the RegistryRoot.* constants.keyName
- the name of the key without a leading backslash.valueName
- the name of the registry value.public static boolean setValue(RegistryRoot root, java.lang.String keyName, java.lang.String valueName, java.lang.Object value)
root
- one of the RegistryRoot.* constantskeyName
- the name of the key without a leading backslash.valueName
- the name of the registry value.value
- an instance of one of the following classes: String, Integer,
String[], byte[], WinRegistry.ExpandString.public static void deleteValue(RegistryRoot root, java.lang.String keyName, java.lang.String valueName)
root
- one of the RegistryRoot.* constants.keyName
- the name of the key without a leading backslash.valueName
- the name of the registry value.public static void deleteKey(RegistryRoot root, java.lang.String keyName, boolean onlyIfEmpty)
root
- one of the RegistryRoot.* constants.keyName
- the name of the key without a leading backslash.onlyIfEmpty
- if true, the method will delete the key only if the key contains no
values and no sub-key.public static java.lang.String[] getSubKeyNames(RegistryRoot root, java.lang.String keyName)
root
- one of the RegistryRoot.* constants.keyName
- the name of the key without a leading backslash.public static java.lang.String[] getValueNames(RegistryRoot root, java.lang.String keyName)
root
- one of the RegistryRoot.* constants.keyName
- the name of the key without a leading backslash.public static boolean saveKey(RegistryRoot root, java.lang.String keyName, java.lang.String fileName)
root
- one of the RegistryRoot.* constants.keyName
- the name of the key without a leading backslash. This is the root of the saved sub-tree.fileName
- the file to which the sub-tree should be saved.restoreKey(RegistryRoot, String, String)
public static boolean restoreKey(RegistryRoot root, java.lang.String keyName, java.lang.String fileName)
root
- one of the RegistryRoot.* constants.keyName
- the name of the key without a leading backslash. This is the key to which the root of the saved sub-tree
will be restored.fileName
- the file from which the saved sub-tree should be read.saveKey(RegistryRoot, String, String)
public static boolean keyExists(RegistryRoot root, java.lang.String keyName, RegistryView registryView)
root
- one of the RegistryRoot.* constants.keyName
- the name of the key without a leading backslash.registryView
- the registry view used on 64-bit systems.public static boolean createKey(RegistryRoot root, java.lang.String keyName, RegistryView registryView)
root
- one of the RegistryRoot.* constants.keyName
- the name of the key without a leading backslash.registryView
- the registry view used on 64-bit systems.public static java.lang.Object getValue(RegistryRoot root, java.lang.String keyName, java.lang.String valueName, RegistryView registryView)
root
- one of the RegistryRoot.* constants.keyName
- the name of the key without a leading backslash.valueName
- the name of the registry value.registryView
- the registry view used on 64-bit systems.public static boolean setValue(RegistryRoot root, java.lang.String keyName, java.lang.String valueName, java.lang.Object value, RegistryView registryView)
root
- one of the RegistryRoot.* constantskeyName
- the name of the key without a leading backslash.valueName
- the name of the registry value.value
- an instance of one of the following classes: String, Integer,
String[], byte[], WinRegistry.ExpandString.registryView
- the registry view used on 64-bit systems.public static void deleteValue(RegistryRoot root, java.lang.String keyName, java.lang.String valueName, RegistryView registryView)
root
- one of the RegistryRoot.* constants.keyName
- the name of the key without a leading backslash.valueName
- the name of the registry value.registryView
- the registry view used on 64-bit systems.public static void deleteKey(RegistryRoot root, java.lang.String keyName, boolean onlyIfEmpty, RegistryView registryView)
root
- one of the RegistryRoot.* constants.keyName
- the name of the key without a leading backslash.onlyIfEmpty
- if true, the method will delete the key only if the key contains no
values and no sub-key.registryView
- the registry view used on 64-bit systems.public static java.lang.String[] getSubKeyNames(RegistryRoot root, java.lang.String keyName, RegistryView registryView)
root
- one of the RegistryRoot.* constants.keyName
- the name of the key without a leading backslash.registryView
- the registry view used on 64-bit systems.public static java.lang.String[] getValueNames(RegistryRoot root, java.lang.String keyName, RegistryView registryView)
root
- one of the RegistryRoot.* constants.keyName
- the name of the key without a leading backslash.registryView
- the registry view used on 64-bit systems.
null if the key doesn't exist or if an error occurs.public static boolean saveKey(RegistryRoot root, java.lang.String keyName, java.lang.String fileName, RegistryView registryView)
root
- one of the RegistryRoot.* constants.keyName
- the name of the key without a leading backslash. This is the root of the saved sub-tree.fileName
- the file to which the sub-tree should be saved.registryView
- the registry view used on 64-bit systems.restoreKey(RegistryRoot, String, String)
public static boolean restoreKey(RegistryRoot root, java.lang.String keyName, java.lang.String fileName, RegistryView registryView)
root
- one of the RegistryRoot.* constants.keyName
- the name of the key without a leading backslash. This is the key to which the root of the saved sub-tree
will be restored.fileName
- the file from which the saved sub-tree should be read.registryView
- the registry view used on 64-bit systems.saveKey(RegistryRoot, String, String)