Description
Create or open a registry key. Static
Syntax
Regkey.create(keyname[, class[, samDesired]])
Parameters
| Name | Meaning |
| HKCR | HKEY_CLASSES_ROOT |
| HKCC | HKEY_CURRENT_CONFIG |
| HKCU | HKEY_CURRENT_USER |
| HKLM | HKEY_LOCAL_MACHINE |
| HKU | HKEY_USERS |
| HKPD | HKEY_PERFORMANCE_DATA |
| HKDD | HKEY_DYN_DATA |
| Value | Name | Meaning |
| 0 | KEY_ALL_ACCESS | Combination of KEY_QUERY_VALUE, KEY_ENUMERATE_SUB_KEYS, KEY_NOTIFY, KEY_CREATE_SUB_KEY, KEY_CREATE_LINK, and KEY_SET_VALUE access |
| 1 | KEY_CREATE_LINK | Permission to create a symbolic link |
| 2 | KEY_CREATE_SUB_KEY | Permission to create subkeys |
| 3 | KEY_ENUMERATE_SUB_KEYS | Permission to enumerate subkeys |
| 4 | KEY_EXECUTE | Permission for read access |
| 5 | KEY_NOTIFY | Permission for change notification |
| 6 | KEY_QUERY_VALUE | Permission to query subkey data |
| 7 | KEY_READ | Combination of KEY_QUERY_VALUE, KEY_ENUMERATE_SUB_KEYS, and KEY_NOTIFY access |
| 8 | KEY_SET_VALUE | Permission to set subkey data |
| 9 | KEY_WRITE | Combination of KEY_SET_VALUE and KEY_CREATE_SUB_KEY access |
Returns
If the key specified by the keyname already exists, it opens the key and returns a new instance of the RegKey Object. Otherwise it creates a new key in the registry and returns a new instance of the RegKey Object. If failed, returns null.
Example
r = new RegKey("HKCU\\Software\\Demo1");
//create a sub key of r
sub = r.create("subkey");
//creates "HKCU\Software\Demo1\subkey"
//create a key under HKEY_CURRENT_USER
sub2 = r.create("HKCU\\Software\\Demo2");
sub3 = RegKey.create("HKCU\\Software\\Demo2");
sub4 = RegKey.create("subkey");
//returns null because there is no root for "subkey"