RegDeleteKeyEx Function
RegDeleteKeyEx Function

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

To delete a subkey as a transacted operation, call the RegDeleteKeyTransacted function.

Syntax

C++
LONG WINAPI RegDeleteKeyEx(
  __in        HKEY hKey,
  __in        LPCTSTR lpSubKey,
  __in        REGSAM samDesired,
  __reserved  DWORD Reserved
);

Parameters

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
lpSubKey [in]

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.

samDesired [in]

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

ValueMeaning
KEY_WOW64_32KEY
0x0200

Delete the key from the 32-bit registry view.

KEY_WOW64_64KEY
0x0100

Delete the key from the 64-bit registry view.

 

Reserved

This parameter is reserved and must be zero.

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.

Remarks

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, RegDeleteKeyEx removes the specified key from the registry. The entire key, including all of its values, is removed.

Requirements

Minimum supported clientWindows Vista, Windows XP Professional x64 Edition
Minimum supported serverWindows Server 2008, Windows Server 2003 with SP1
HeaderWinreg.h (include Windows.h)
LibraryAdvapi32.lib
DLLAdvapi32.dll
Unicode and ANSI namesRegDeleteKeyExW (Unicode) and RegDeleteKeyExA (ANSI)

See Also

RegCreateKeyEx
RegDeleteKeyTransacted
Registry Redirector
Registry Functions
RegOpenKeyEx

Send comments about this topic to Microsoft

Build date: 11/19/2009

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Examples Examples Examples      PerlDude   |   Edit   |   Show History

One of the greats reasons for the spread of Borland C++ was the fact that their documentation was unparalled. Every document of any API, keyword had what?
Examples, Examples, Examples, Examples.

Do you want me to say again :). Please help MS tools to spread. Make life easy. Concentrate on Examples. A GM a VP should pick this and make it a goal.

Tags What's this?: Add a tag
Flag as ContentBug
Processing
Page view tracker