RegDeleteKey

  LONG RegDeleteKey(hkey, lpszSubKey)    
  HKEY hkey; /* handle of an open key */
  LPTSTR lpszSubKey; /* address of name of subkey to delete */

The RegDeleteKey function deletes the specified key. This function cannot be used to delete a key if the key has subkeys.

Parameters

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

lpszSubKey must be a subkey of hkey.

lpszSubKey

Points to a null-terminated string specifying the key to delete. This parameter must not be NULL, and the specified key must not have subkeys.

Return Value

The return value is ERROR_SUCCESS if the function is successful. Otherwise, it is an error value.

Comments

The RegDeleteKey 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).

If successful, RegDeleteKey removes the specified key from the registration database. The entire key, including all of its values, will be removed.

The key specified by lpszSubKey must have been opened with DELETE access. Use the RegCreateKeyEx or RegOpenKeyEx function to open the key.

See Also

RegCloseKey