RegDeleteKeyValueW function (winreg.h)

Removes the specified value from the specified registry key and subkey.


LSTATUS RegDeleteKeyValueW(
  [in]           HKEY    hKey,
  [in, optional] LPCWSTR lpSubKey,
  [in, optional] LPCWSTR lpValueName


[in] hKey

A handle to an open registry key. The key must have been opened with the KEY_SET_VALUE access right. For more information, see Registry Key Security and Access Rights.

This handle is returned by the RegCreateKeyEx or RegOpenKeyEx function, or it can be one of the following predefined keys:


[in, optional] lpSubKey

The name of the registry key. This key must be a subkey of the key identified by the hKey parameter.

[in, optional] lpValueName

The registry value to be removed from the key.

Return value

If the function succeeds, the return value is ERROR_SUCCESS.

If the function fails, the return value is a nonzero error code defined in Winerror.h. You can use the FormatMessage function with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a generic description of the error.


To compile an application that uses this function, define _WIN32_WINNT as 0x0600 or later. For more information, see Using the Windows Headers.


On legacy versions of Windows, this API is also exposed by kernel32.dll.


The winreg.h header defines RegDeleteKeyValue 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.


Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header winreg.h (include Windows.h)
Library Advapi32.lib
DLL Advapi32.dll

See also


Registry Functions