Package com.ms.lang Previous
Previous
Microsoft Packages
Microsoft Packages
Index
Index
Next
Next

Class RegKey

Constructor , Fields , Methods

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;

	// Constructor
	public RegKey(RegKey rkParent, String subKey, boolean createIfNess);

	// Methods
	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 byte[] getBinaryValue(String name);
	public int getIntValue(String name);
	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();
}

This class produces registry access objects.


Constructor


RegKey

public RegKey(RegKey rkParent, String subKey, boolean createIfNess)

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

Return Value:

Returns the newly created registry key.

ParameterDescription
rk Identifies a currently open key or any of the following predefined reserved handle values:
null
HKEY_CLASSES_ROOT
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_USERS

The key created is a subkey of the key identified by the rk parameter. If the applet is running in a browser, or other protected environment, this parameter must be null. This specifies that the key will be created in a sandboxed section of the registry.

subKey Points 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 rk parameter. This subkey must not begin with the backslash character ('\'). This parameter cannot be null.
create If this is true and the key does not exist, the key will be created

Throws:

SecurityException If the parent key is not accessible.

IOExceptionIf the key can not be created.


Fields

KEYOPEN_READ
Identifier signifying a key should be opened for read access.
KEYOPEN_WRITE
Identifier signifying a key should be opened for write access.
KEYOPEN_ALL
Identifier signifying a key should be opened for read and write access.
KEYOPEN_CREATE
Identifier signifying a key should be created but not opened.
CLASSES_ROOT
Identifier signifying that HKEY_CLASSES_ROOT should be returned.
LOCALMACHINE_ROOT
Identifier signifying that the HKEY_LOCAL_MACHINE key should be returned.
USER_ROOT
Identifier signifying that the HKEY_CURRENT_USER key should be returned.
USERS_ROOT
Identifier signifying that the HKEY_USERS key should be returned.

See also Class RegKey.


Methods


finalize

public void finalize()

Cleans up the registry key, closing it if open.

Return Value:

No return value.


close

public void close()

Closes the key.

Return Value:

No return value.

Remarks:

Use close when the key is no longer needed. This ensures that the system registry keys are written to disk. After closing, the key must not be used again.


deleteSubKey

public void deleteSubKey(String sub)

Removes a subkey from the key.

Return Value:

No return value.

ParameterDescription
sub The subkey to remove.

Throws:

IOException if unsuccessful.


deleteValue

public void deleteValue(String val)

Deletes a value from the key.

Return Value:

No return value.

ParameterDescription
val The name of the value to be deleted.


enumValue

public RegKeyEnumValue enumValue(int idx)

Enumerates subvalues of the key.

Return Value:

Returns the value of the provided index.

ParameterDescription
idx Index of the enumeration.


enumKey

public String  enumKey(int idx)

Enumerates subkeys of the key.

Return Value:

Returns the name of the subkey.

ParameterDescription
idx Index of the enumeration.


flush

public void flush()

Flushes the key to the registry on disk.

Return Value:

No return value.


loadKey

public void loadKey(String subKey, String fileName)

Loads a new hive into the registry.

ParameterDescription
subKey Name of the subkey to be created to contain the new hive.
fileName Name of a file containing the registry information.


getStringValue

public String getStringValue(String name)

Retrieves a String value from the registry. The name is a sub key of the current key.

Return Value:

Returns a String value contained in the subKey.

ParameterDescription
name Name of the subKey containing the value wanted.


getBinaryValue

public byte[] getBinaryValue(String name)

Retrieve a byte array from the registry. The name is a sub key of the current key.

Return Value:

Returns the byte array contained in the subKey.

ParameterDescription
name subKey containing the value wanted.


getIntValue

public int getIntValue(String name)

Retrieve an integer value from the registry. The name is a sub key of the current key.

Return Value:

Returns the integer value contained in the subKey.

ParameterDescription
name subKey containing the value wanted.


replace

public void replace(String subKey, String newFile, String oldFile)

Replaces the file backing a key and all its subkeys with another file, so that when the system is next started, the key and subkeys will have the values stored in the new file.

Return Value:

No return value.

ParameterDescription
subKey Name of the sub key to replace.
newFile Name of the file containing the new values.
oldFile Name of the file to receive a backup copy of the old values.


restore

public void restore( String filename, boolean vol )

Restores a subkey from a file.

Return Value:

No return value.

ParameterDescription
file Name of the file containing the subkey.
volatile True if the hive is to be volatile.


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


queryInfo

public RegQueryInfo queryInfo()

Retrieves information about the key.

Return Value:

Returns a RegQueryInfo object which contains the information.



Top© 1996 Microsoft Corporation. All rights reserved.