Interface Win32RegistryService
-
- All Superinterfaces:
Service
public interface Win32RegistryService extends Service
This service provides access to the Win32 Registry for reading and writing registry data. This service is provided only on the Win32 platforms.In each method, if Win32 returns an error code from any of the registry API's, the method throws a ServiceException containing a description of the error as reported by Win32. This description ends with the actual error code displayed in parentheses.
-
-
Field Summary
Fields Modifier and Type Field Description static int
HKEY_CLASSES_ROOT
One of the hive values that can be passed to the Win32Registry service API's.static int
HKEY_CURRENT_CONFIG
One of the hive values that can be passed to the Win32Registry service API's.static int
HKEY_CURRENT_USER
One of the hive values that can be passed to the Win32Registry service API's.static int
HKEY_LOCAL_MACHINE
One of the hive values that can be passed to the Win32Registry service API's.static int
HKEY_USERS
One of the hive values that can be passed to the Win32Registry service API's.static int
INVALID_HIVE
A setting for an invalid hive.static java.lang.String
NAME
static int
REG_BINARY
Possible return value of the getValueType method.static int
REG_DWORD
Possible return value of the getValueType method.static int
REG_DWORD_BIG_ENDIAN
Possible return value of the getValueType method.static int
REG_DWORD_LITTLE_ENDIAN
Possible return value of the getValueType method.static int
REG_EXPAND_SZ
Possible return value of the getValueType method.static int
REG_FULL_RESOURCE_DESCRIPTOR
Possible return value of the getValueType method.static int
REG_LINK
Possible return value of the getValueType method.static int
REG_MULTI_SZ
Possible return value of the getValueType method.static int
REG_NONE
Possible return value of the getValueType method.static int
REG_RESOURCE_LIST
Possible return value of the getValueType method.static int
REG_RESOURCE_REQUIREMENTS_LIST
Possible return value of the getValueType method.static int
REG_SZ
Possible return value of the getValueType method.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description int
countSubKeys(int hive, java.lang.String key)
Returns the number of subkeys directly under the key.int
countValuesInKey(int hive, java.lang.String key)
Returns the number of values that are stored directly in the key (not including values stored in subkeys).void
createKey(int hive, java.lang.String parentKey, java.lang.String subKeyToCreate)
Creates a new, empty subkey under the specified parent key within the specified "hive".void
deleteKey(int hive, java.lang.String parentKey, java.lang.String subKeyToDelete, boolean bErrorIfKeyMissing)
Deletes the specified key.void
deleteValue(int hive, java.lang.String key, java.lang.String valueName, boolean bErrorIfValueMissing)
Deletes the specified value from the registry.int
get32BitValue(int hive, java.lang.String key, java.lang.String valueName)
Returns a 32 bit registry value.byte[]
getBinaryValue(int hive, java.lang.String key, java.lang.String valueName)
Returns a binary registry value.java.lang.String[]
getKeyValueNames(int hive, java.lang.String key)
Returns the names of each of the values stored in the specified key.java.lang.String[]
getMultiStringValue(int hive, java.lang.String key, java.lang.String valueName)
Returns a multi string registry value.java.lang.String
getStringValue(int hive, java.lang.String key, java.lang.String valueName, boolean expand)
Returns a string registry value.java.lang.String[]
getSubkeyNames(int hive, java.lang.String key)
Returns the names of each of the immediate subkeys below the specified key.int
getValueType(int hive, java.lang.String key, java.lang.String valueName)
Returns the data type of the specified value in the registry.boolean
isKeyEmpty(int hive, java.lang.String key)
Returns true if the specified key contains no values and no subkeys.boolean
keyExists(int hive, java.lang.String key)
Returns true if the specified key exists in the Win32 registry.int
longestSubKeyNameLength(int hive, java.lang.String key)
Returns the length of the longest subkey name whose parent is the specified key.int
longestValueNameData(int hive, java.lang.String key)
Returns the length of the longest value data (in bytes) stored in the specified key.int
longestValueNameLength(int hive, java.lang.String key)
Returns the length of the longest value name stored in the specified key.void
set32BitValue(int hive, java.lang.String key, java.lang.String valueName, int value)
Set a registry value to the specified 32 bit value.void
setBinaryValue(int hive, java.lang.String key, java.lang.String valueName, byte[] value)
Set a registry value to the specified binary value.void
setMultiStringValue(int hive, java.lang.String key, java.lang.String valueName, java.lang.String[] value)
Set a registry value to the specified multi string value.void
setStringValue(int hive, java.lang.String key, java.lang.String valueName, boolean expandable, java.lang.String value)
Set a registry value to the specified string.boolean
valueExists(int hive, java.lang.String key, java.lang.String valueName)
-
Methods inherited from interface com.installshield.wizard.service.Service
cancelOperation, getName, getOperationProgress, getServiceImplementorType, isNoopMode, isOperationCanceled, isOperationEnded, isOperationSuspended, resumeOperation, setNoopMode, suspendOperation
-
-
-
-
Field Detail
-
NAME
static final java.lang.String NAME
-
REG_NONE
static final int REG_NONE
Possible return value of the getValueType method.- See Also:
- Constant Field Values
-
REG_SZ
static final int REG_SZ
Possible return value of the getValueType method.- See Also:
- Constant Field Values
-
REG_EXPAND_SZ
static final int REG_EXPAND_SZ
Possible return value of the getValueType method.- See Also:
- Constant Field Values
-
REG_BINARY
static final int REG_BINARY
Possible return value of the getValueType method.- See Also:
- Constant Field Values
-
REG_DWORD
static final int REG_DWORD
Possible return value of the getValueType method.- See Also:
- Constant Field Values
-
REG_DWORD_LITTLE_ENDIAN
static final int REG_DWORD_LITTLE_ENDIAN
Possible return value of the getValueType method.- See Also:
- Constant Field Values
-
REG_DWORD_BIG_ENDIAN
static final int REG_DWORD_BIG_ENDIAN
Possible return value of the getValueType method.- See Also:
- Constant Field Values
-
REG_LINK
static final int REG_LINK
Possible return value of the getValueType method.- See Also:
- Constant Field Values
-
REG_MULTI_SZ
static final int REG_MULTI_SZ
Possible return value of the getValueType method.- See Also:
- Constant Field Values
-
REG_RESOURCE_LIST
static final int REG_RESOURCE_LIST
Possible return value of the getValueType method.- See Also:
- Constant Field Values
-
REG_FULL_RESOURCE_DESCRIPTOR
static final int REG_FULL_RESOURCE_DESCRIPTOR
Possible return value of the getValueType method.- See Also:
- Constant Field Values
-
REG_RESOURCE_REQUIREMENTS_LIST
static final int REG_RESOURCE_REQUIREMENTS_LIST
Possible return value of the getValueType method.- See Also:
- Constant Field Values
-
HKEY_CLASSES_ROOT
static final int HKEY_CLASSES_ROOT
One of the hive values that can be passed to the Win32Registry service API's. This corresponds directly to the HKEY_CLASSES_ROOT portion of the registry. Please see the Win32 SDK documentation for additional information.- See Also:
- Constant Field Values
-
HKEY_CURRENT_CONFIG
static final int HKEY_CURRENT_CONFIG
One of the hive values that can be passed to the Win32Registry service API's. This corresponds directly to the HKEY_CURRENT_CONFIG portion of the registry. Please see the Win32 SDK documentation for additional information.- See Also:
- Constant Field Values
-
HKEY_CURRENT_USER
static final int HKEY_CURRENT_USER
One of the hive values that can be passed to the Win32Registry service API's. This corresponds directly to the HKEY_CURRENT_USER portion of the registry. Please see the Win32 SDK documentation for additional information.- See Also:
- Constant Field Values
-
HKEY_LOCAL_MACHINE
static final int HKEY_LOCAL_MACHINE
One of the hive values that can be passed to the Win32Registry service API's. This corresponds directly to the HKEY_LOCAL_MACHINE portion of the registry. Please see the Win32 SDK documentation for additional information.- See Also:
- Constant Field Values
-
HKEY_USERS
static final int HKEY_USERS
One of the hive values that can be passed to the Win32Registry service API's. This corresponds directly to the HKEY_USERS portion of the registry. Please see the Win32 SDK documentation for additional information.- See Also:
- Constant Field Values
-
INVALID_HIVE
static final int INVALID_HIVE
A setting for an invalid hive.- See Also:
- Constant Field Values
-
-
Method Detail
-
createKey
void createKey(int hive, java.lang.String parentKey, java.lang.String subKeyToCreate) throws ServiceException
Creates a new, empty subkey under the specified parent key within the specified "hive". The newly created key is non-volatile. If the key already exists, this method is a no-op, and no exception occurs.To create values within this key, use the set*Value methods in this service.
- Parameters:
hive
- One of the hive values defined by this service.parentKey
- The registry path of the key that is to be the parent of the new subkey. Can be null or "" if you wish to create a subkey directly below the hive (not allowed by Win32 for HKEY_LOCAL_MACHINE or HKEY_USERS).subKeyToCreate
- The name of the new child key.- Throws:
ServiceException
- See Also:
Win32 platform SDK documentation for RegCreateKeyEx.
,setStringValue
,setMultiStringValue
,set32BitValue
,setBinaryValue
-
deleteKey
void deleteKey(int hive, java.lang.String parentKey, java.lang.String subKeyToDelete, boolean bErrorIfKeyMissing) throws ServiceException
Deletes the specified key. If you wish to delete the keyHKEY_LOCAL_MACHINE\SOFTWARE\Widget Company\Widget Software
,
you would call deleteKey as follows:
deleteKey (HKEY_LOCAL_MACHINE, "SOFTWARE\Widget Company", "Widget Software", false);
This method will delete the specified key even if it has values and/or subkeys. Though the RegDeleteKey on NT and Windows 2000 does not do this automatically, the Win32 registry service will enumerate all the descendant keys and delete them before attempting to delete the specified key. If you do not want non-empty keys to be deleted, then call isKeyEmpty, countValuesInKey, or countSubKeys prior to calling this method.
- Parameters:
hive
- One of the hive values defined by this service.parentKey
- The registry path of the key that is to be the parent of the new subkey. Can be null or "" if you wish to delete a subkey directly below the hive (not allowed by Win32 for HKEY_LOCAL_MACHINE or HKEY_USERS).subKeyToDelete
- The name of the child key to delete (cannot be null or "").bErrorIfKeyMissing
- If true and the specified key is missing, an exception is thrown.- Throws:
ServiceException
- See Also:
Win32 platform SDK documentation for RegDeleteKey.
,isKeyEmpty
,countValuesInKey
,countSubKeys
-
keyExists
boolean keyExists(int hive, java.lang.String key) throws ServiceException
Returns true if the specified key exists in the Win32 registry.- Parameters:
hive
- One of the hive values defined by this service.parentKey
- The registry path of the key to check.- Throws:
ServiceException
-
isKeyEmpty
boolean isKeyEmpty(int hive, java.lang.String key) throws ServiceException
Returns true if the specified key contains no values and no subkeys.- Parameters:
hive
- One of the hive values defined by this service.key
- The registry path of the key to check.- Throws:
ServiceException
-
countValuesInKey
int countValuesInKey(int hive, java.lang.String key) throws ServiceException
Returns the number of values that are stored directly in the key (not including values stored in subkeys). Using the Win32 RegQueryInfoKey API, this method returns the value returned in the lpcValues parameter.- Parameters:
hive
- One of the hive values defined by this service.key
- The registry path of the key in which to count values.- Throws:
ServiceException
- See Also:
Win32 platform SDK documentation for RegQueryInfoKey.
-
countSubKeys
int countSubKeys(int hive, java.lang.String key) throws ServiceException
Returns the number of subkeys directly under the key. Using the Win32 RegQueryInfoKey API, this method returns the value returned in the lpcSubKeys parameter.- Parameters:
hive
- One of the hive values defined by this service.key
- The registry path of the key in which to count subkeys.- Throws:
ServiceException
- See Also:
Win32 platform SDK documentation for RegQueryInfoKey.
-
longestSubKeyNameLength
int longestSubKeyNameLength(int hive, java.lang.String key) throws ServiceException
Returns the length of the longest subkey name whose parent is the specified key. Using the Win32 RegQueryInfoKey API, this method returns the value returned in the lpcMaxSubKeyLen parameter.- Parameters:
hive
- One of the hive values defined by this service.key
- The registry path of the key to check.- Throws:
ServiceException
- See Also:
Win32 platform SDK documentation for RegQueryInfoKey.
-
longestValueNameLength
int longestValueNameLength(int hive, java.lang.String key) throws ServiceException
Returns the length of the longest value name stored in the specified key. Using the Win32 RegQueryInfoKey API, this method returns the value returned in the lpcMaxValueNameLen parameter.- Parameters:
hive
- One of the hive values defined by this service.key
- The registry path of the key to check.- Throws:
ServiceException
- See Also:
Win32 platform SDK documentation for RegQueryInfoKey.
-
longestValueNameData
int longestValueNameData(int hive, java.lang.String key) throws ServiceException
Returns the length of the longest value data (in bytes) stored in the specified key. Using the Win32 RegQueryInfoKey API, this method returns the value returned in the lpcMaxValueLen parameter.- Parameters:
hive
- One of the hive values defined by this service.key
- The registry path of the key to check.- Throws:
ServiceException
- See Also:
Win32 platform SDK documentation for RegQueryInfoKey.
-
setStringValue
void setStringValue(int hive, java.lang.String key, java.lang.String valueName, boolean expandable, java.lang.String value) throws ServiceException
Set a registry value to the specified string. If the expandable flag is true, then the type of the string in the Win32 registry will be REG_EXPAND_SZ. Otherwise, it will be REG_SZ. The expandable string is useful for cases where a Win32 environment variable name is to be included in the value and can be "expanded" (resolved to the actual setting for that environment variable) at the time that the value retrieved.- Parameters:
hive
- One of the hive values defined by this service.key
- The registry path of the key to which this value should be added.valueName
- The name of the value to add.expandable
- If true, the value type in the registry will be REG_EXPAND_SZ, otherwise the value type in the registry will be REG_SZ.value
- The actual string to store in the registry.- Throws:
ServiceException
- See Also:
Win32 platform SDK documentation for RegSetValueEx.
-
setMultiStringValue
void setMultiStringValue(int hive, java.lang.String key, java.lang.String valueName, java.lang.String[] value) throws ServiceException
Set a registry value to the specified multi string value.- Parameters:
hive
- One of the hive values defined by this service.key
- The registry path of the key to which this value should be added.valueName
- The name of the value to add.value
- The multiple strings to store in the registry.- Throws:
ServiceException
- See Also:
Win32 platform SDK documentation for RegSetValueEx.
-
set32BitValue
void set32BitValue(int hive, java.lang.String key, java.lang.String valueName, int value) throws ServiceException
Set a registry value to the specified 32 bit value. The type of the value in the registry will be REG_DWORD.- Parameters:
hive
- One of the hive values defined by this service.key
- The registry path of the key to which this value should be added.valueName
- The name of the value to add.value
- The actual 32 bit value to store in the registry.- Throws:
ServiceException
- See Also:
Win32 platform SDK documentation for RegSetValueEx.
-
setBinaryValue
void setBinaryValue(int hive, java.lang.String key, java.lang.String valueName, byte[] value) throws ServiceException
Set a registry value to the specified binary value. The type of the value in the registry will be REG_BINARY.- Parameters:
hive
- One of the hive values defined by this service.key
- The registry path of the key to which this value should be added.valueName
- The name of the value to add.value
- The actual binary value to store in the registry. The length of the array determines the number of bytes written to the registry.- Throws:
ServiceException
- See Also:
Win32 platform SDK documentation for RegSetValueEx.
-
deleteValue
void deleteValue(int hive, java.lang.String key, java.lang.String valueName, boolean bErrorIfValueMissing) throws ServiceException
Deletes the specified value from the registry.- Parameters:
hive
- One of the hive values defined by this service.key
- The registry path of the key from which this value will be deleted.valueName
- The name of the value to delete.bErrorIfValueMissing
- If true and the specified value is missing, an exception is thrown.- Throws:
ServiceException
- See Also:
Win32 platform SDK documentation for RegDeleteValue.
-
getStringValue
java.lang.String getStringValue(int hive, java.lang.String key, java.lang.String valueName, boolean expand) throws ServiceException
Returns a string registry value. If the expand flag is true, and the registry type for that value is REG_EXPAND_SZ, then any embedded environment variables will be replaced with their corresponding values. If the type of the value in the registry is not REG_SZ or REG_EXPAND_SZ, a ServiceException will be thrown.- Parameters:
hive
- One of the hive values defined by this service.key
- The registry path of the key from which this value should be gotten.valueName
- The name of the value for which to return the string value.expand
- If true, the value gotten from the registry will have any environment variable references replaced by the actual values of those environment variables.- Returns:
- The actual string value gotten from the registry.
- Throws:
ServiceException
- See Also:
Win32 platform SDK documentation for RegQueryValueEx.
,Win32 platform SDK documentation for ExpandEnvironmentStrings.
-
getMultiStringValue
java.lang.String[] getMultiStringValue(int hive, java.lang.String key, java.lang.String valueName) throws ServiceException
Returns a multi string registry value. Each of the strings contained in the value is stored as one element in the returned array. The length of the array matches the number of strings stored in the value. If the the data type of the value is not REG_MULTI_SZ, a ServiceException will be thrown.- Parameters:
key
- The registry path of the key from which this value should be gotten.valueName
- The name of the value for which to return the string values.- Returns:
- The actual string values gotten from the registry.
- Throws:
ServiceException
- See Also:
Win32 platform SDK documentation for RegQueryValueEx.
-
get32BitValue
int get32BitValue(int hive, java.lang.String key, java.lang.String valueName) throws ServiceException
Returns a 32 bit registry value. If the type of the value in the registry is not REG_DWORD, a ServiceException will be thrown.- Parameters:
hive
- One of the hive values defined by this service.key
- The registry path of the key from which this value should be gotten.valueName
- The name of the value for which to return the 32 bit value.- Returns:
- The actual 32 bit value gotten from the registry.
- Throws:
ServiceException
- See Also:
Win32 platform SDK documentation for RegQueryValueEx.
-
getBinaryValue
byte[] getBinaryValue(int hive, java.lang.String key, java.lang.String valueName) throws ServiceException
Returns a binary registry value. If the type of the value in the registry is not REG_BINARY, a ServiceException will be thrown.- Parameters:
hive
- One of the hive values defined by this service.key
- The registry path of the key from which this value should be gotten.valueName
- The name of the value for which to return the binary value.- Returns:
- The actual binary value gotten from the registry. The array will contain the same number of entries as the number of bytes returned from the registry.
- Throws:
ServiceException
- See Also:
Win32 platform SDK documentation for RegQueryValueEx.
-
getKeyValueNames
java.lang.String[] getKeyValueNames(int hive, java.lang.String key) throws ServiceException
Returns the names of each of the values stored in the specified key.- Parameters:
hive
- One of the hive values defined by this service.key
- The registry path of the key for which to get the value names.- Returns:
- An array of strings with each of the value names.
- Throws:
ServiceException
- See Also:
Win32 platform SDK documentation for RegEnumValue.
-
getSubkeyNames
java.lang.String[] getSubkeyNames(int hive, java.lang.String key) throws ServiceException
Returns the names of each of the immediate subkeys below the specified key.- Parameters:
hive
- One of the hive values defined by this service.key
- The registry path of the key for which to get the subkey names.- Returns:
- An array of strings with each of the subkey names.
- Throws:
ServiceException
- See Also:
Win32 platform SDK documentation for RegEnumKey.
-
getValueType
int getValueType(int hive, java.lang.String key, java.lang.String valueName) throws ServiceException
Returns the data type of the specified value in the registry. The returned value will be one of
- REG_BINARY
- REG_DWORD
- REG_DWORD_LITTLE_ENDIAN (unsupported at this time, but this is the same as REG_DWORD)
- REG_DWORD_BIG_ENDIAN (unsupported at this time)
- REG_EXPAND_SZ
- REG_MULTI_SZ
- REG_NONE
- REG_QWORD (unsupported at this time)
- REG_QWORD_LITTLE_ENDIAN (unsupported at this time)
- REG_RESOURCE_LIST (unsupported at this time)
- REG_SZ
- Throws:
ServiceException
-
valueExists
boolean valueExists(int hive, java.lang.String key, java.lang.String valueName) throws ServiceException
- Throws:
ServiceException
-
-