Interface SimpleRegistryManager
-
public interface SimpleRegistryManager
Used to access the Win32 system Registry.
The Windows Registry is organized into keys which can contain other keys or can contain values. A value has a name (called a value name) to identify it within a key, and can contain data. This version of SimpleRegistryManager supports three built-in data types: string, DWORD, and byte array. The corresponding Java types used to represent this data are
String
,Integer
, andbyte[]
.Every key has at least one value, which is usually denoted as the default value or "
@
". When using these SimpleRegistryManager APIs, a null string specified for the value name will refer to the default value.NOTE: A key path is the full path name that refers to the key where the value will be set. Remember that the Windows Registry uses backslashes within path name. To specify a backslash in Java, it must be escaped: (
\\
).The key path should never begin with a backslash. Typically, it will start with HKEY_LOCAL_MACHINE or another similar root branch name.
An example key path might be:
HKEY_LOCAL_MACHINE\SOFTWARE\Zero G Software, Inc.\InstallAnywhere\3.0
As Java code, the above would be written as:
String keyPath = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Zero G Software, Inc.\\InstallAnywhere\\5.0";
A value in the above key might have the value name
Home
The data in that value could be a
String
and may look something like:
D:\Program Files\InstallAnywhere 5 Enterprise
To facilitate the interaction with the Windows Registry, Zero G has written several extensions that make use and extend the functionality of the SimpleRegistryManager. Two of these extensions (SimpleRegistryManagerPlus and SpeedRegistry) are now bundled with the Enterprise and Standard Editions of InstallAnywhere and include source code (look in the '<InstallAnywhere Folder>/CustomCode/Samples' directory. To download additional InstallAnywhere extensions, please visit:
http://support.acresso.com/
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
createRegistryKey(java.lang.String keyPath)
This method creates a new registry key.boolean
deleteRegistryKey(java.lang.String keyPath)
This method deletes a key from the registry.boolean
deleteRegistryKeyValue(java.lang.String keyPath, java.lang.String valueName)
This method deletes a value from the registry.java.lang.Object
getRegistryKeyValue(java.lang.String keyPath, java.lang.String valueName)
This method returns the data associated with a value.boolean
setRegistryKeyValue(java.lang.String keyPath, java.lang.String valueName, java.lang.Object value)
This method sets the data in a value, specified by the key path and value name.
-
-
-
Method Detail
-
setRegistryKeyValue
boolean setRegistryKeyValue(java.lang.String keyPath, java.lang.String valueName, java.lang.Object value)
This method sets the data in a value, specified by the key path and value name.
If the value does not exist under a certain key, it will be created and its data set.
- Parameters:
keyPath
- the full path name that refers to the key where the value will be set.valueName
- the identifier for this specific value / data pair.value
- what you want to set the value to. You can send aString
,Integer
, orbyte[]
.- Returns:
true
if the value was successfully set, and created if necessary,false
if the value could not be set. Usually this means that the key path is wrong, or you don't have the required permissions to set the value.
-
getRegistryKeyValue
java.lang.Object getRegistryKeyValue(java.lang.String keyPath, java.lang.String valueName)
This method returns the data associated with a value.
- Parameters:
keyPath
- the full path name that refers to the key where the value is located.valueName
- the identifier for this specific value / data pair (or value).- Returns:
- the value's data as an Object or
null
if the data could not be found or accessed (likely due to an incorrect path or value name). You can cast this to a String, Integer, or byte[], or you can compare it's class to find out what kind of data it is.
-
deleteRegistryKeyValue
boolean deleteRegistryKeyValue(java.lang.String keyPath, java.lang.String valueName)
This method deletes a value from the registry.
- Parameters:
keyPath
- the full path name that refers to the key where the value is located.valueName
- is the identifier for this specific value / data pair (or value).- Returns:
true
if the value was successfully found and removed.false
if the value could not be found or could not be removed. Usually this means thatkeyPath
is wrong, orvalueName
is wrong.
-
createRegistryKey
boolean createRegistryKey(java.lang.String keyPath)
This method creates a new registry key.
If necessary, all of the keys leading up to the key to create will also be created if they do not already exist.
- Parameters:
keyPath
- the full path name that refers to the new key to create.- Returns:
true
if the key was successfully created,false
if the key could not be created. Usually this means thatkeyPath
is wrong (root-level keys [likeHKEY_LOCAL_MACHINE
] cannot be created), or that a key exists already for that path.
-
deleteRegistryKey
boolean deleteRegistryKey(java.lang.String keyPath)
This method deletes a key from the registry.
All subkeys and all values of the key to be deleted will automatically be removed.
- Type Parameters:
code
- keyPath is the full path name that refers to the key that will be removed.- Returns:
true
if the key was successfully found and removed.false
if the value could not be found or could not be removed. Usually this means thatkeyPath
is wrong, or that the key specified does not exist.
-
-