Share via


RegDeleteKey

This function deletes a named subkey from the specified registry key.

A remote application interface (RAPI) version of this function exists, and it is called CeRegDeleteKey.

LONG RegDeleteKey( 
HKEY hKey, 
LPCWSTR lpSubKey );

Parameters

  • hKey
    [in] Handle to a currently open key or one of the following predefined reserved handle values:

    • HKEY_CLASSES_ROOT
    • HKEY_CURRENT_USER
    • HKEY_LOCAL_MACHINE
    • HKEY_USERS

    The key specified by the lpSubKey parameter must be a subkey of the key identified by hKey.

  • lpSubKey
    [in] Pointer to a null-terminated string specifying the name of the key to delete. This parameter cannot be NULL.

Return Values

ERROR_SUCCESS indicates success. A nonzero error code defined in Winerror.h indicates failure. To get a generic description of the error, call FormatMessage with the FORMAT_MESSAGE_FROM_SYSTEM flag set. The message resource is optional; therefore, if you call FormatMessage it could fail.

Remarks

If the function succeeds, RegDeleteKey removes the specified key from the registry. The entire key, including all of its values, is removed. An application cannot call RegDeleteKey for a key that an application currently has open.

To open the key, use the RegCreateKeyEx or RegOpenKeyEx function.  

Requirements

Runs on Versions Defined in Include Link to
Windows CE OS 1.0 and later Winreg.h   Coredll.lib, Fsreg.lib

Note   This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.

See Also

RegCloseKey, RegCreateKeyEx, RegOpenKeyEx

 Last updated on Tuesday, July 13, 2004

© 1992-2000 Microsoft Corporation. All rights reserved.