RegistryDeleteValue

Windows Mobile 6.5
A version of this page is also available for
4/8/2010

This function deletes a specified registry value.


HRESULT WINAPI RegistryDeleteValue( 
  HKEY hKey
  LPCTSTR pszSubKey,
  LPCTSTR pszValueName
);

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).

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.

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.

The following code example demonstrates how to use RegistryDeleteValue.

Bb154485.note(en-us,MSDN.10).gifNote:
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);
}

Headerregext.h
Libraryaygshell.lib
Windows Embedded CEWindows Embedded CE 6.0 and later
Windows MobilePocket PC for Windows Mobile Version 5.0 and later, Smartphone for Windows Mobile Version 5.0 and later

Community Additions

Show: