Package com.ms.lang Previous
Previous
Contents
Contents
Index
Index
Next
Next

Class RegKey

Constructors , Methods , Fields

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.


Constructors


RegKey

public RegKey(RegKey rkParent, String subKey, int access)

Creates the specified key. If the key already exists in the registry, the function opens it.

ParameterDescription
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.


RegKey

public RegKey(int rootID, String subKey, int access)

A convenience constructor that performs Regkey.getRootKey automatically.

ParameterDescription
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.


RegKey

public RegKey(int rootID, String subKey)

Opens a key for reading.

ParameterDescription
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.


Methods


close

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.


deleteSubKey

public void deleteSubKey(String sub)

Removes a subkey from the key.

Return Value:

No return value.

ParameterDescription
sub The section to prune from the key.

Exceptions:

IOException occurs if the pruning is unsuccessful.


deleteValue

public void deleteValue(String val)

Deletes a value from the key.

ParameterDescription
val The name of the value that is deleted.


enumKey

public String enumKey(int idx)

Enumerates subkeys of the key.

Return Value:

Returns the enumeration of the key.

ParameterDescription
idx The index of the enumeration.


enumValue

public RegKeyEnumValue enumValue(int idx)

Enumerates subvalues of the key.

Return Value:

Returns the subkey name of the subkey.

ParameterDescription
idx The index of the enumeration.


finalize

public void finalize()

Frees the resources associated with a RegKey object.

Return Value:

No return value.


flush

public void flush()

Flushes the key to the registry on disk.

Return Value:

No return value.


getBinaryValue

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.

ParameterDescription
name The subKey containing the value wanted.


getIntValue

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.

ParameterDescription
name The subKey containing the value wanted.


getIntValue

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.

ParameterDescription
name The subkey containing the value wanted.
defval The default value.


getRootKey

public final static RegKey getRootKey(int id)

Retrieves a top-level key.

ParameterDescription
id The ID of the top-level key.


getStringValue

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.

ParameterDescription
name The subKey containing the value wanted.


getStringValue

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.

ParameterDescription
name The subkey containing the value wanted.
defval The default value.


loadKey

public void loadKey(String subKey, String fileName)

Loads a new hive into the registry.

Return Value:

No return value.

ParameterDescription
subKey The name of the subkey to create that contains the new hive.
hive The name of a file containing the registry information.


queryInfo

public RegQueryInfo queryInfo()

Retreives information about the key.

Return Value:

Returns a RegQueryInfo object that contains the information.


replace

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.

ParameterDescription
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.


restore

public void restore( String filename, boolean vol )

Restores a subkey from a file.

Return Value:

No return value.

ParameterDescription
filename The file name.
vol The value returned is true if the hive is volatile. Otherwise, the value is false.


setValue

public void setValue(String subKey, String val)

Sets a String value into a subkey.

Return Value:

No return value.

ParameterDescription
subKey The subkey to hold the value.
val The string to write out.


setValue

public void setValue(String subKey, byte val[])

Sets a byte array into a subkey.

Return Value:

No return value.

ParameterDescription
subKey The subkey to hold the value.
val [] The array to write out.


setValue

public void setValue(String subKey, int val)

Sets an integer value into a subkey.

Return Value:

No return value.

ParameterDescription
subKey The subkey to hold the value.
val The integer to write out.


unload

public void unload(String subKey)

Unloads a hive from the registry.

Return Value:

No return value.

ParameterDescription
subKey The subkey to unload.


Fields

CLASSES_ROOT
ID signifying that the HKEY_CLASSES_ROOT key should be returned.
KEYOPEN_ALL
ID signifying a key should be opened for ALL access.
KEYOPEN_CREATE
ID signifying a key should be created, not opened.
KEYOPEN_READ
ID signifying a key should be opened for READ access.
KEYOPEN_WRITE
ID signifying a key should be opened for WRITE access.
LOCALMACHINE_ROOT
ID signifying that the HKEY_LOCAL_MACHINE key should be returned.
USER_ROOT
ID signifying that the HKEY_CURRENT_USER key should be returned.
USERS_ROOT
ID signifying that the HKEY_USERS key should be returned.


Top© 1997 Microsoft Corporation. All rights reserved. Legal Notices.