Click to Rate and Give Feedback
MSDN
MSDN Library
User Interface
Windows Shell
Shell Reference
Registry Functions
 SHDeleteKey Function

  Switch on low bandwidth view
SHDeleteKey Function

Deletes a subkey and all its descendants. The function will remove the key and all of the key's values from the registry.

Syntax

LSTATUS SHDeleteKey(      
    HKEY hkey,     LPCTSTR pszSubKey );

Parameters

hkey
[in] A handle to the currently open key, or any of the following predefined values.
HKEY_CLASSES_ROOT
HKEY_CURRENT_CONFIG
HKEY_CURRENT_USER
HKEY_DYN_DATA (MicrosoftWindows95 only)
HKEY_LOCAL_MACHINE
HKEY_PERFORMANCE_DATA (Microsoft Windows NTonly)
HKEY_USERS
pszSubKey
[in] The address of a null-terminated string specifying the name of the key to delete.

Return Value

Returns ERROR_SUCCESS if successful, or a nonzero error code defined in Winerror.h otherwise. You can use the FormatMessage function with the FORMAT_MESSAGE_FROM_SYSTEM flag to retrieve a generic description of the error.

Function Information

Minimum DLL Versionshlwapi.dll version 4.71 or later
Custom ImplementationNo
Headershlwapi.h
Import libraryshlwapi.lib
Minimum operating systems Windows 2000, Windows NT 4.0 with Internet Explorer 4.0, Windows 98, Windows 95 with Internet Explorer 4.0
UnicodeImplemented as ANSI and Unicode versions.
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
use RegDeleteTree() on Vista or above instead      Chris_Guzak   |   Edit   |   Show History

on Vista this functionality is supported in the base OS via RegDeleteTree()

http://msdn.microsoft.com/en-us/library/aa379776(VS.85).aspx

Note that RegDeleteKey() does not recurse and will fail on keys with subkeys

Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker