SHDeleteEmptyKeyA function (shlwapi.h)

Deletes an empty key.

Syntax

LSTATUS SHDeleteEmptyKeyA(
  HKEY   hkey,
  LPCSTR pszSubKey
);

Parameters

hkey

Type: HKEY

A handle to an open registry key, or one of the following predefined keys:

HKEY_CLASSES_ROOT

HKEY_CURRENT_CONFIG

HKEY_CURRENT_USER

HKEY_LOCAL_MACHINE

HKEY_PERFORMANCE_DATA

HKEY_USERS

pszSubKey

Type: LPCTSTR

The address of a null-terminated string specifying the name of the key to delete.

Return value

Type: LSTATUS

Returns ERROR_SUCCESS if successful, or a nonzero error code defined in Winerror.h otherwise. You can use the FormatMessage function with the FORMAT_MESSAGE_FROM_SYSTEM flag to retrieve a generic description of the error.

Remarks

SHDeleteEmptyKey does not delete a key if it contains any subkeys or values. Use SHDeleteKey instead.

Alternatively, use the RegDeleteKey or RegDeleteTree function.

Note

The shlwapi.h header defines SHDeleteEmptyKey as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

Requirements

   
Minimum supported client Windows 2000 Professional, Windows XP [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header shlwapi.h
Library Shlwapi.lib
DLL Shlwapi.dll (version 4.71 or later)