RegDeleteKeyTransactedA function (winreg.h)

Deletes a subkey and its values from the specified platform-specific view of the registry as a transacted operation. Note that key names are not case sensitive.


LSTATUS RegDeleteKeyTransactedA(
  [in] HKEY   hKey,
  [in] LPCSTR lpSubKey,
  [in] REGSAM samDesired,
       DWORD  Reserved,
  [in] HANDLE hTransaction,
       PVOID  pExtendedParameter


[in] hKey

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, RegCreateKeyTransacted, RegOpenKeyEx, or RegOpenKeyTransacted function. It can also be one of the following predefined keys:


[in] lpSubKey

The name of the key to be deleted. This key must be a subkey of the key specified by the value of the hKey parameter.

The function opens the subkey with the DELETE access right.

Key names are not case sensitive.

The value of this parameter cannot be NULL.

[in] samDesired

An access mask the specifies the platform-specific view of the registry.

Value Meaning
Delete the key from the 32-bit registry view.
Delete the key from the 64-bit registry view.


This parameter is reserved and must be zero.

[in] hTransaction

A handle to an active transaction. This handle is returned by the CreateTransaction function.


This parameter is reserved and must be NULL.

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.


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

On WOW64, 32-bit applications view a registry tree that is separate from the registry tree that 64-bit applications view. This function enables an application to delete an entry in the alternate registry view.

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.

If the function succeeds, RegDeleteKeyTransacted removes the specified key from the registry. The entire key, including all of its values, is removed. To remove the entire tree as a transacted operation, use the RegDeleteTree function with a handle returned from RegCreateKeyTransacted or RegOpenKeyTransacted.


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


Requirement Value
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

Registry Redirector