RegistryDeleteValue
A version of this page is also available for
4/8/2010
This function deletes a specified registry value.
Syntax
HRESULT WINAPI RegistryDeleteValue(
HKEY hKey
LPCTSTR pszSubKey,
LPCTSTR pszValueName
);
Parameters
- hKey
Handle to a currently open key, or a predefined root value.
- pszSubKey
The key under which the value is stored (if this value is NULL, pszValueName is assumed to be under hKey).
- pszValueName
The name of the value to delete (if this parameter is NULL, the default value is deleted).
Return Value
Value | Description |
---|---|
S_OK |
The value was deleted successfully. |
S_FALSE |
The key or value does not exist. |
E_INVALIDARG |
Invalid hKey. |
An error value returned. |
Error value wrapped as a FACILITY_WIN32 HRESULT. |
Remarks
The value under the hKey+pszSubKey will be deleted if it exists, if the value does not exist, there is no change and this method will succeed.
If the key pointed to by hKey+pszSubKey does not exist, RegistryDeleteValue will fail since it uses RegOpenKey to access the key.
Code Example
The following code example demonstrates how to use RegistryDeleteValue.
Note
To make the following code example easier to read, security checking and error handling are not included. This code example should not be used in a release configuration unless it has been modified to include them.
void ClearRegistrySettings()
{
HKEY hkey;
// Clear one value from HKEY_LOCAL_MACHINE.
RegistryDeleteValue(HKEY_LOCAL_MACHINE,
TEXT("Software\\MyApplication"),
TEXT("SystemValue"));
// Re-use the HKEY_CURRENT_USER handle.
0,
0,
&hkey);
RegistryDeleteValue(hkey, NULL, TEXT("UserValue1"));
RegistryDeleteValue(hkey, NULL, TEXT("UserValue2"));
// Clean up
RegCloseKey(hkey);
}
Requirements
Header | regext.h |
Library | aygshell.lib |
Windows Embedded CE | Windows Embedded CE 6.0 and later |
Windows Mobile | Pocket PC for Windows Mobile Version 5.0 and later, Smartphone for Windows Mobile Version 5.0 and later |
See Also
Reference
State and Notifications Broker Functions
State and Notifications Broker Reference