|
Servertec Foundation Classes 1.3.3 09/04/2005 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectstec.sfc.Win32.RegistryKey
public final class RegistryKey
Used to create, change and remove registry entries and to access predefined registry keys.
WARNING: EXTREME CAUTION AND CARE SHOULD BE USED WHEN USING THE METHODS IN THIS CLASS AND WHEN CHANGING THE REGISTRY. NUMEROUS BUGS EXIST IN THE WIN32 API THAT MAY RESULT IN SYSTEM CORRUPTION AND LOSS. USING THIS CLASS MAY RESULT IN THE NEED TO REINSTALL THE COMPUTER FROM SCRATCH.
Field Summary | |
---|---|
static RegistryKey |
CLASSES_ROOT
Contains subkeys and values defining types, classes, documents and properties. |
static RegistryKey |
CURRENT_CONFIG
Contains subkeys and values defining the local computer's current hardware configuration. |
static RegistryKey |
CURRENT_USER
Contains subkeys and values defining the current user's preferences. |
static RegistryKey |
DYN_DATA
Normally used by Windows 9x to store performance data. |
static RegistryKey |
LOCAL_MACHINE
Contains subkeys and values defining the standard hardware and software configuration of the comptuer. |
static RegistryKey |
PERFORMANCE_DATA
Normally used by Windows NT/2000/XP to store performance data. |
static RegistryKey |
USERS
Contains subkeys and values for the default configuration setting used by the current user and new users. |
Constructor Summary | |
---|---|
RegistryKey(RegistryKey hkey,
java.lang.String subkey)
Constructs a new RegistryKey from the specified RegistryKey and subkey. |
|
RegistryKey(java.lang.String hostname,
RegistryKey hkey)
Constructs a new RegistryKey at the specified computer and RegistryKey. |
Method Summary | |
---|---|
void |
close()
Closes the RegistryKey. |
RegistryKey |
createKey(java.lang.String subkey)
Creates a new RegistryKey subkey to the current RegistryKey. |
void |
deleteKey(java.lang.String subkey)
Deletes the specified subkey to the current RegistryKey. |
void |
deleteKey(java.lang.String subkey,
boolean recursive)
Deletes the specified subkey to the current RegistryKey. |
void |
deleteValue(java.lang.String name)
Deletes the named value in the current RegistryKey. |
void |
flush()
Writes changes to the Registry file. |
byte[] |
getBinary(java.lang.String name)
Returns the binary array associated with the specified value. |
java.lang.String |
getExpandString(java.lang.String name)
Returns the expanded string associated with the specified value. |
int |
getInt(java.lang.String name)
Returns the integer associated with the specified value. |
long |
getLong(java.lang.String name)
Returns the long integer associated with the specified value. |
java.lang.String |
getPath()
Returns the full registry path for the current RegistryKey. |
int |
getRawData(byte[] buffer)
Returns the data contained at the current key. |
int |
getRawData(java.lang.String name,
byte[] buffer)
Returns the data contained at the specified value. |
java.lang.String |
getString(java.lang.String name)
Returns the string associated with the specified value. |
java.lang.String[] |
getStringArray(java.lang.String name)
Returns the string array associated with the specified value. |
int |
getSubKeyCount()
Returns the number of keys in the current RegistryKey. |
java.lang.String |
getSubKeyName(int index)
Returns the name of the specified subkey in the current RegistryKey. |
int |
getValueCount()
Returns the number of values in the current RegistryKey. |
int |
getValueData(int index,
byte[] buffer)
Returns the data contained at the specified value in the current RegistryKey. |
int |
getValueData(int index,
byte[] buffer,
int length)
Returns the data contained at the specified value in the current RegistryKey. |
int |
getValueData(int index,
byte[] buffer,
int offset,
int length)
Returns the data contained at the specified value in the current RegistryKey. |
int |
getValueData(java.lang.String name,
byte[] buffer)
Returns the data contained at the named value in the current RegistryKey. |
int |
getValueData(java.lang.String name,
byte[] buffer,
int length)
Returns the data contained at the named value. |
int |
getValueData(java.lang.String name,
byte[] buffer,
int offset,
int length)
Returns the data contained at the specified value. |
int |
getValueDataLength(int index)
Returns the length of the data value for the specified value. |
int |
getValueDataLength(java.lang.String name)
Returns the length of the data value for the named value. |
int |
getValueDataType(int index)
Returns the data type of the specified value. |
int |
getValueDataType(java.lang.String name)
Returns the data type of the named value. |
java.lang.String |
getValueName(int index)
Returns the name of the specified value in the current RegistryKey. |
void |
load(java.lang.String subkey,
java.lang.String filename)
Loads the saved registry entries into the named subkey into the current RegistryKey from the specified file. |
void |
save(java.lang.String filename)
Saves the current RegistryKey to the specified file. |
void |
setBinary(java.lang.String name,
byte[] bytes)
Associates the specified binary array value with the given value name. |
void |
setExpandString(java.lang.String name,
java.lang.String s)
Associates the specified expanded string value with the given value name. |
void |
setInt(java.lang.String name,
int i)
Associates the specified integer value with the given value name. |
void |
setLong(java.lang.String name,
long l)
Associates the specified long integer value with the given value name. |
void |
setString(java.lang.String name,
java.lang.String s)
Associates the specified string value with the given value name. |
void |
setStringArray(java.lang.String name,
java.lang.String[] sarray)
Associates the specified string array value with the given value name. |
void |
setValue(java.lang.String name,
int type,
byte[] value)
Adds or changes the named value in the current RegistryKey with the given value of the specified type. |
void |
setValue(java.lang.String name,
int type,
byte[] value,
int length)
Adds or changes the named value in the current RegistryKey with the given value of the specified type. |
void |
setValue(java.lang.String name,
int type,
byte[] buffer,
int offset,
int length)
Adds or changes the named value in the current RegistryKey with the given value of the specified type starting at the given offset. |
boolean |
subKeyExists(java.lang.String subkey)
Returns whether the specified subkey exists. |
boolean |
valueExists(java.lang.String name)
Returns whether the specified value exists. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final RegistryKey CLASSES_ROOT
Used by COM applications, file viewers, user interface extensions and in-process servers.
Set to HKEY_CLASSES_ROOT.
public static final RegistryKey CURRENT_CONFIG
Standard hardware configuration information is normally stored in LOCAL_MACHINE.
Set to HKEY_CURRENT_CONFIG.
public static final RegistryKey CURRENT_USER
Normally stores settings such as application preferences, environment variables, program groups, printers and network connections.
Commonly used by software vendors to store the current user's application preferences.
Set to HKEY_CURRENT_USER.
public static final RegistryKey DYN_DATA
Set to HKEY_DYN_DATA.
public static final RegistryKey LOCAL_MACHINE
Normally stores information about the hardware and software installed on the computer, the bus type, system memory, Plug and Play, network logon, network security settings, server names and the location of the server.
Set to HKEY_LOCAL_MACHINE.
public static final RegistryKey PERFORMANCE_DATA
Set to HKEY_PERFORMANCE_DATA.
public static final RegistryKey USERS
Set to HKEY_USERS.
Constructor Detail |
---|
public RegistryKey(RegistryKey hkey, java.lang.String subkey) throws Win32Exception, java.lang.IllegalArgumentException
hkey
- the base RegistryKey.subkey
- the name of the subkey.
java.lang.IllegalArgumentException
- if subkey is empty.
Win32Exception
- if any error occurs.public RegistryKey(java.lang.String hostname, RegistryKey hkey) throws Win32Exception, java.lang.IllegalArgumentException
hostname
- the computer to connect to. null for the current computer.hkey
- the base RegistryKey.
java.lang.IllegalArgumentException
- if hostname is empty.
Win32Exception
- if any error occurs.Method Detail |
---|
public final void close() throws Win32Exception
Win32Exception
- if any error occurs.public final void flush() throws Win32Exception, java.io.IOException
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if any error occurs.public final void load(java.lang.String subkey, java.lang.String filename) throws Win32Exception, java.io.IOException
WARNING: THIS METHOD IS KNOWN TO CORRUPT THE SYSTEM REGISTRY.
When running Windows 9x/Me this method does not support use of long path names.
subkey
- the key name to load into.filename
- the name of the file to load.
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if any error occurs.public final void save(java.lang.String filename) throws Win32Exception, java.io.IOException
filename
- the name of the file.
When running Windows 9x long file names cannot be specified.
When running Windows 9x the registry file has the system, hidden, read-only and archive file attribute and when running Windows NT/2000 the registry file has the archive file attribute.
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if the file already exists or if any error occurs.public final java.lang.String getPath() throws Win32Exception, java.io.IOException
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if any error occurs.public final RegistryKey createKey(java.lang.String subkey) throws Win32Exception, java.io.IOException
subkey
- the subkey to create.
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if any error occurs.public final void deleteKey(java.lang.String subkey) throws Win32Exception, java.io.IOException
This method will delete all subkeys and values when used under Windows 9x, but will not when used under Windows NT/2000/XP.
subkey
- the subkey to delete.
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- ir the specified subkey does not exist or if any error occurs.public final void deleteKey(java.lang.String subkey, boolean recursive) throws Win32Exception, java.io.IOException
subkey
- the subkey to delete.recursive
- whether to delete subkeys
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- ir the specified subkey does not exist or if any error occurs.
An exception is not thrown when recursive is false and the subkey is not empty.
public final void deleteValue(java.lang.String name) throws Win32Exception, java.io.IOException
name
- the name of the value to delete.
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if any error occurs.public final int getSubKeyCount() throws Win32Exception, java.io.IOException
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if any error occurs.public final int getValueCount() throws Win32Exception, java.io.IOException
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if any error occurs.public final java.lang.String getSubKeyName(int index) throws Win32Exception, java.io.IOException
index
- the index of the subkey.
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if any error occurs.public final java.lang.String getValueName(int index) throws Win32Exception, java.io.IOException
index
- the index of the value.
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if any error occurs.public final int getValueDataType(int index) throws Win32Exception, java.io.IOException
index
- the index of the value.
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if any error occurs.public final int getValueDataType(java.lang.String name) throws Win32Exception, java.io.IOException
name
- the name of the value.
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if any error occurs.public final int getValueDataLength(int index) throws Win32Exception, java.io.IOException
index
- the index of the value.
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if any error occurs.public final int getValueDataLength(java.lang.String name) throws Win32Exception, java.io.IOException
name
- the name of the value.
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if any error occurs.public final int getValueData(java.lang.String name, byte[] buffer, int offset, int length) throws Win32Exception, java.io.IOException, java.lang.ArrayIndexOutOfBoundsException, java.lang.IllegalArgumentException
name
- the name of the value.buffer
- the byte array where the value's data will be placed.offset
- the starting offsetlength
- the number of bytes to load.
java.lang.IllegalArgumentException
- if the specified offset is less than zero or greater than or equal to the given byte array size or if the specified number of bytes to get is larger than the remaining space in the specified given byte array.
java.lang.ArrayIndexOutOfBoundsException
- if the length specified is not large enough to contain the value.
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if any error occurs.public final int getValueData(java.lang.String name, byte[] buffer, int length) throws Win32Exception, java.io.IOException, java.lang.ArrayIndexOutOfBoundsException, java.lang.IllegalArgumentException
name
- the name of the value.buffer
- the byte array where the value's data will be placed.length
- the number of bytes to load.
java.lang.IllegalArgumentException
- if the specified offset is less than zero or greater than or equal to the given byte array size or if the specified number of bytes to get is larger than the remaining space in the specified given byte array.
java.lang.ArrayIndexOutOfBoundsException
- if the length specified is not large enough to contain the value.
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if any error occurs.public final int getValueData(java.lang.String name, byte[] buffer) throws Win32Exception, java.io.IOException, java.lang.ArrayIndexOutOfBoundsException
name
- the named value.buffer
- the byte array where the value's data will be placed.
java.lang.ArrayIndexOutOfBoundsException
- if the length specified is not large enough to contain the value.
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if any error occurs.public final int getValueData(int index, byte[] buffer, int offset, int length) throws Win32Exception, java.io.IOException, java.lang.IllegalArgumentException, java.lang.ArrayIndexOutOfBoundsException
index
- the index of the value.buffer
- the byte array where the value's data will be placed.offset
- the starting offsetlength
- the number of bytes to load.
java.lang.IllegalArgumentException
- if the specified offset is less than zero or greater than or equal to the given byte array size or if the specified number of bytes to get is larger than the remaining space in the specified given byte array.
java.lang.ArrayIndexOutOfBoundsException
- if the length specified is not large enough to contain the value.
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if any error occurs.public final int getValueData(int index, byte[] buffer, int length) throws Win32Exception, java.io.IOException, java.lang.IllegalArgumentException, java.lang.ArrayIndexOutOfBoundsException
index
- the index of the value.buffer
- the byte array where the value's data will be placed.length
- the number of bytes to load.
java.lang.IllegalArgumentException
- if the specified offset is less than zero or greater than or equal to the given byte array size or if the specified number of bytes to get is larger than the remaining space in the specified given byte array.
java.lang.ArrayIndexOutOfBoundsException
- if the length specified is not large enough to contain the value.
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if any error occurs.public final int getValueData(int index, byte[] buffer) throws Win32Exception, java.io.IOException, java.lang.ArrayIndexOutOfBoundsException
index
- the index of the value.buffer
- the byte array where the value's data will be placed.
java.lang.ArrayIndexOutOfBoundsException
- if the length specified is not large enough to contain the value.
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if any error occurs.public final void setValue(java.lang.String name, int type, byte[] buffer, int offset, int length) throws Win32Exception, java.io.IOException, java.lang.IllegalArgumentException
name
- the value's name.type
- the RegistryValueType.buffer
- the byte array containing the value.offset
- the starting offset.length
- the size of the value.
java.lang.IllegalArgumentException
- if the specified offset is less than zero or greater than or equal to the given byte array size or if the specified number of bytes to set is larger than the remaining space in the specified given byte array.
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if any error occurs.public final void setValue(java.lang.String name, int type, byte[] value, int length) throws Win32Exception, java.io.IOException, java.lang.IllegalArgumentException
name
- the value's name.type
- the RegistryValueType.value
- the byte array containing the value.length
- the size of the value.
java.lang.IllegalArgumentException
- if the specified offset is less than zero or greater than or equal to the given byte array size or if the specified number of bytes to set is larger than the remaining space in the specified given byte array.
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if any error occurs.public final void setValue(java.lang.String name, int type, byte[] value) throws Win32Exception, java.io.IOException
name
- the value's name.type
- the RegistryValueType.value
- the byte array containing the value.
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if any error occurs.public final boolean subKeyExists(java.lang.String subkey) throws Win32Exception, java.io.IOException, java.lang.IllegalArgumentException
subkey
- the specified subkey to test.
java.lang.IllegalArgumentException
- is subkey is empty.
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if any error occurs.public final boolean valueExists(java.lang.String name) throws Win32Exception, java.io.IOException
name
- the name of the value.
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if any error occurs.public final java.lang.String getString(java.lang.String name) throws Win32Exception, java.io.IOException, java.lang.ClassCastException
name
- the name of the value.
java.lang.ClassCastException
- if the associated value is not a STRING.
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if any error occurs.public final java.lang.String getExpandString(java.lang.String name) throws Win32Exception, java.io.IOException, java.lang.ArrayIndexOutOfBoundsException, java.lang.ClassCastException
name
- the name of the value.
java.lang.ClassCastException
- if the associated value is not a EXPAND_STRING.
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if any error occurs.
java.lang.ArrayIndexOutOfBoundsException
public final java.lang.String[] getStringArray(java.lang.String name) throws Win32Exception, java.io.IOException, java.lang.ArrayIndexOutOfBoundsException, java.lang.ClassCastException
name
- the name of the value.
java.lang.ClassCastException
- if the associated value is not a STRING_ARRAY.
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if any error occurs.
java.lang.ArrayIndexOutOfBoundsException
public final int getInt(java.lang.String name) throws Win32Exception, java.io.IOException, java.lang.ArrayIndexOutOfBoundsException, java.lang.ClassCastException
name
- the name of the value.
java.lang.ClassCastException
- if the associated value is not a DWORD.
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if any error occurs.
java.lang.ArrayIndexOutOfBoundsException
public final long getLong(java.lang.String name) throws Win32Exception, java.io.IOException, java.lang.ArrayIndexOutOfBoundsException, java.lang.ClassCastException
name
- the name of the value.
java.lang.ClassCastException
- if the associated value is not a QWORD.
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if any error occurs.
java.lang.ArrayIndexOutOfBoundsException
public final byte[] getBinary(java.lang.String name) throws Win32Exception, java.io.IOException, java.lang.ArrayIndexOutOfBoundsException, java.lang.ClassCastException
name
- the name of the value.
java.lang.ClassCastException
- if the associated value is not a BINARY.
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if any error occurs.
java.lang.ArrayIndexOutOfBoundsException
public final void setString(java.lang.String name, java.lang.String s) throws Win32Exception, java.io.IOException
name
- the name of the value.s
- the string value.
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if any error occurs.public final void setExpandString(java.lang.String name, java.lang.String s) throws Win32Exception, java.io.IOException
name
- the name of the value.s
- the expanded string value.
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if any error occurs.public final void setStringArray(java.lang.String name, java.lang.String[] sarray) throws Win32Exception, java.io.IOException
name
- the name of the value.sarray
- the string array value.
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if any error occurs.public final void setInt(java.lang.String name, int i) throws Win32Exception, java.io.IOException
name
- the name of the value.i
- the integer value.
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if any error occurs.public final void setLong(java.lang.String name, long l) throws Win32Exception, java.io.IOException
name
- the name of the value.l
- the long integer value.
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if any error occurs.public final void setBinary(java.lang.String name, byte[] bytes) throws Win32Exception, java.io.IOException
name
- the name of the value.bytes
- the binary array value.
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if any error occurs.public final int getRawData(byte[] buffer) throws java.lang.IllegalArgumentException, Win32Exception, java.io.IOException
buffer
- the byte array where the data will be placed.
java.lang.IllegalArgumentException
- if the buffer's length is 0.
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if any error occurs.public final int getRawData(java.lang.String name, byte[] buffer) throws java.lang.IllegalArgumentException, Win32Exception, java.io.IOException
name
- the name of the value.buffer
- the byte array where the data will be placed.
java.lang.IllegalArgumentException
- if the buffer's length is 0.
java.io.IOException
- if this RegistryKey has been closed.
Win32Exception
- if any error occurs.
|
Servertec Foundation Classes 1.3.3 09/04/2005 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 2001-2005 Servertec. All rights reserved.