LONG RegCreateKey(hkey, lpszSubKey, phkResult) | |||||
HKEY hkey; | /* handle of an open key | */ | |||
LPTSTR lpszSubKey; | /* address of name of subkey to open | */ | |||
PHKEY phkResult; | /* address of buffer for opened handle | */ |
The RegCreateKey function creates the specified key. If the key already exists in the registration database, the function opens it.
hkey
Identifies a currently open key or any of the following predefined reserved handle values:
HKEY_CLASSES_ROOT HKEY_CURRENT_USER HKEY_LOCAL_MACHINE HKEY_USERS
The key opened or created by this function is a subkey of the key identified by hkey.
lpszSubKey
Points to a null-terminated string specifying the subkey to open or create. lpszSubKey is always relative to the key specified by hkey. This value must not be NULL.
phkResult
Points to a variable that receives the handle of the key that is opened or created.
The return value is ERROR_SUCCESS if the function is successful. Otherwise, it is an error value.
An application can use the RegCreateKey function to create several keys at once. For example, an application could create a subkey four levels deep and the three preceding subkeys by specifying a string of the following form for the lpszSubKey parameter:
subkey1\subkey2\subkey3\subkey4
The key specified by hkey must have been opened with KEY_CREATE_SUB_KEY access (KEY_WRITE access includes KEY_CREATE_SUB_KEY).
The RegCreateKey function may be used as either a wide-character function (where text arguments must use Unicode) or an ANSI function (where text arguments must use characters from the Windows 3.x character set installed).
RegCloseKey RegCreateKeyEx, RegOpenKey, RegOpenKeyEx, RegSetValue