RegistryKey.createSubKey

Overview | Methods | This Package | All Packages

RegistryKey.createSubKey

Creates a new subkey.

Syntax

public RegistryKey createSubKey( String subkey )

Parameters

subkey

A String object that represents the name or path of the subkey to create.

Return Value

Returns the subkey, or returns null if the operation fails.

Remarks

The createSubKey method is typically used to create a subkey of a RegistryKey object and assign it to a new RegistryKey object. If the key you are creating already exists, the key is opened and assigned to the RegistryKey object you are instantiating. To create a tree of subkeys, define each new subkey with a backslash (\). Remember, to use a double backslash (\\) with strings in quotation marks in the Java language. You can use the createSubKey method to create a location under one of the registry's root keys to store your application's information.

The following example illustrates how to create a RegistryKey object that creates new subkeys. It uses the Registry class members to access the CURRENT_USER root key.

RegistryKey myKey = Registry.CURRENT_USER.createSubKey("Software\\MyCompany\\MyApplication");