Package com.ms.lang |
![]() Previous |
![]() Contents |
![]() Index |
![]() Next |
public class RegKey { // Fields public final static int KEYOPEN_READ = 1; public final static int KEYOPEN_WRITE = 2; public final static int KEYOPEN_ALL = 3; public final static int KEYOPEN_CREATE = 4; public final static int CLASSES_ROOT = 1; public final static int LOCALMACHINE_ROOT = 2; public final static int USER_ROOT = 3; public final static int USERS_ROOT = 4; // Constructors public RegKey(RegKey rkParent, String subKey, int access) public RegKey(int rootID, String subKey,int access) public RegKey(int rootID, String subKey) // Methods public final static RegKey getRootKey(int id) public void finalize() public void close() public void deleteSubKey(String sub) public void deleteValue(String val) public RegKeyEnumValue enumValue(int idx) public String enumKey(int idx) public void flush() public void loadKey(String subKey, String fileName) public String getStringValue(String name) public String getStringValue(String name, String defval) public byte[] getBinaryValue(String name) public int getIntValue(String name) public int getIntValue(String name, int defval) public void replace(String subKey, String newFile, String oldFile) public void restore( String filename, boolean vol ) public void setValue(String subKey, String val) public void setValue(String subKey, byte val[]) public void setValue(String subKey, int val) public void unload(String subKey) public RegQueryInfo queryInfo() }
The RegKey class produces registry access objects. The access objects listed below, however, are not implemented.
public RegKey(RegKey rkParent, String subKey, int access)Creates the specified key. If the key already exists in the registry, the function opens it.
Parameter Description rkParent The currently open key or any of the following predefined reserved handle values: null, HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, and HKEY_USERS. The key created is a subkey of the key identified by the rkParent parameter. If the applet is running in a browser or other protected environment, this parameter must be null. subKey The pointer to a String specifying the name of a subkey that this function opens or creates. The subkey specified must be a subkey of the key identified by the rkParent parameter. This subkey must not begin with the backslash character ('\'). This parameter cannot be null. access The access for the key. Exceptions:
RegKeyException occurs if the key cannot be created.
public RegKey(int rootID, String subKey, int access)A convenience constructor that performs Regkey.getRootKey automatically.
Parameter Description rootID The rootID of the key. subKey The pointer to a String specifying the name of a subkey that this function opens or creates. The subkey must not begin with the backslash character ('\'). This parameter cannot be null. access The access for the key.
public RegKey(int rootID, String subKey)Opens a key for reading.
Parameter Description rootID The rootID of the key. subKey The pointer to a String specifying the name of a subkey that this function opens or creates. The subkey must not begin with the backslash character ('\'). This parameter cannot be null.
public void close()Closes a key when the key is no longer needed. As the system registry keys need to be written out to disk, the key should be closed when it is no longer needed. After this, the key should not be used again.
Return Value:
No return value.
public void deleteSubKey(String sub)Removes a subkey from the key.
Return Value:
No return value.
Parameter Description sub The section to prune from the key. Exceptions:
IOException occurs if the pruning is unsuccessful.
public void deleteValue(String val)Deletes a value from the key.
Parameter Description val The name of the value that is deleted.
public String enumKey(int idx)Enumerates subkeys of the key.
Return Value:
Returns the enumeration of the key.
Parameter Description idx The index of the enumeration.
public RegKeyEnumValue enumValue(int idx)Enumerates subvalues of the key.
Return Value:
Returns the subkey name of the subkey.
Parameter Description idx The index of the enumeration.
public void finalize()Frees the resources associated with a RegKey object.
Return Value:
No return value.
public void flush()Flushes the key to the registry on disk.
Return Value:
No return value.
public byte[] getBinaryValue(String name)Queries a byte array from the registry. The name is a subkey of the current key.
Return Value:
Returns the byte array contained in the subKey.
Parameter Description name The subKey containing the value wanted.
public int getIntValue(String name)Queries an integer value from the registry. The name is a subkey of the current key.
Return Value:
Returns the integer value contained in the subKey.
Parameter Description name The subKey containing the value wanted.
public int getIntValue(String name, int defval)Queries an integer value from the registry. The name is a subkey of the current key. If the named value does not exist in the registry, the specified default value is returned.
Return Value:
Returns the integer value contained in the subKey or the default value if the named value does not exist in the registry.
Parameter Description name The subkey containing the value wanted. defval The default value.
public final static RegKey getRootKey(int id)Retrieves a top-level key.
Parameter Description id The ID of the top-level key.
public String getStringValue(String name)Queries a String value from the registry. The name is a subkey of the current key.
Return Value:
Returns the String value contained in the subKey.
Parameter Description name The subKey containing the value wanted.
public String getStringValue(String name, String defval)Queries a String value from the registry. The name is a subkey of the current key. If the named value does not exist in the registry, the specified default value is returned.
Return Value:
Returns the String value contained in the subKey or the default value if the named value does not exist in the registry.
Parameter Description name The subkey containing the value wanted. defval The default value.
public void loadKey(String subKey, String fileName)Loads a new hive into the registry.
Return Value:
No return value.
Parameter Description subKey The name of the subkey to create that contains the new hive. hive The name of a file containing the registry information.
public RegQueryInfo queryInfo()Retreives information about the key.
Return Value:
Returns a RegQueryInfo object that contains the information.
public void replace(String subKey, String newFile, String oldFile)Replaces the file backing a key and all its subkeys with another file. When the system is started next, the key and subkeys will have the values stored in the new file.
Return Value:
No return value.
Parameter Description subKey The subkey whose values are stored in the new file. newFile The name of the new file. oldFile The name of the old file.
public void restore( String filename, boolean vol )Restores a subkey from a file.
Return Value:
No return value.
Parameter Description filename The file name. vol The value returned is true if the hive is volatile. Otherwise, the value is false.
public void setValue(String subKey, String val)Sets a String value into a subkey.
Return Value:
No return value.
Parameter Description subKey The subkey to hold the value. val The string to write out.
public void setValue(String subKey, byte val[])Sets a byte array into a subkey.
Return Value:
No return value.
Parameter Description subKey The subkey to hold the value. val [] The array to write out.
public void setValue(String subKey, int val)Sets an integer value into a subkey.
Return Value:
No return value.
Parameter Description subKey The subkey to hold the value. val The integer to write out.
public void unload(String subKey)Unloads a hive from the registry.
Return Value:
No return value.
Parameter Description subKey The subkey to unload.
© 1997 Microsoft Corporation. All rights reserved. Legal Notices.