Skip to content

Latest commit

 

History

History
151 lines (101 loc) · 5.16 KB

nf-winreg-regdeletekeya.md

File metadata and controls

151 lines (101 loc) · 5.16 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:winreg.RegDeleteKeyA
RegDeleteKeyA function (winreg.h)
Deletes a subkey and its values. (ANSI)
RegDeleteKeyA
winreg/RegDeleteKeyA
base\regdeletekey.htm
winprog
a2310ca0-1b9f-48d1-a3b5-ea3a528bfaba
12/05/2018
RegDeleteKey, RegDeleteKey function, RegDeleteKeyA, RegDeleteKeyW, _win32_regdeletekey, base.regdeletekey, winreg/RegDeleteKey, winreg/RegDeleteKeyA, winreg/RegDeleteKeyW
winreg.h
Windows.h
Windows
Windows 2000 Professional [desktop apps only]
Windows 2000 Server [desktop apps only]
RegDeleteKeyW (Unicode) and RegDeleteKeyA (ANSI)
Advapi32.lib
Advapi32.dll
Windows
19H1
RegDeleteKeyA
winreg/RegDeleteKeyA
c++
APIRef
kbSyntax
DllExport
Advapi32.dll
API-MS-Win-Core-Registry-l2-1-0.dll
advapi32legacy.dll
API-MS-Win-Deprecated-apis-advapi-l1-1-0.dll
API-MS-Win-Core-Registry-l2-2-0.dll
kernel32.dll
RegDeleteKey
RegDeleteKeyA
RegDeleteKeyW

RegDeleteKeyA function

-description

Deletes a subkey and its values. Note that key names are not case sensitive.

64-bit Windows:  On WOW64, 32-bit applications view a registry tree that is separate from the registry tree that 64-bit applications view. To enable an application to delete an entry in the alternate registry view, use the RegDeleteKeyEx function.

-parameters

-param hKey [in]

A handle to an open registry key. The access rights of this key do not affect the delete operation. For more information about access rights, 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:

HKEY_CLASSES_ROOT
HKEY_CURRENT_CONFIG
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_USERS

-param lpSubKey [in]

The name of the key to be deleted. It must be a subkey of the key that hKey identifies, but it cannot have subkeys. This parameter cannot be NULL.

The function opens the subkey with the DELETE access right.

Key names are not case sensitive.

For more information, see Registry Element Size Limits.

-returns

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. To get a generic description of the error, you can use the FormatMessage function with the FORMAT_MESSAGE_FROM_SYSTEM flag.

-remarks

A deleted key is not removed until the last handle to it is closed.

The subkey to be deleted must not have subkeys. To delete a key and all its subkeys, you need to enumerate the subkeys and delete them individually. To delete keys recursively, use the RegDeleteTree or SHDeleteKey function.

Examples

For an example that uses this function, see Deleting a Key with Subkeys.

Note

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

Note

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

-see-also

RegCloseKey

RegCreateKeyEx

RegDeleteTree

RegOpenKeyEx

Registry Functions

Registry Overview

SHDeleteEmptyKey

SHDeleteKey