1 out of 4 rated this helpful Rate this topic

RegDeleteValue function

Removes a named value from the specified registry key. Note that value names are not case sensitive.

Syntax

LONG WINAPI RegDeleteValue(
  __in      HKEY hKey,
  __in_opt  LPCTSTR lpValueName
);

Parameters

hKey [in]

A handle to an open registry key. The key must have been opened with the KEY_SET_VALUE access right. For more information, see Registry Key Security and Access Rights.

This handle is returned by the RegCreateKeyEx, RegCreateKeyTransacted, RegOpenKeyEx, or RegOpenKeyTransacted function. It can also be one of the following predefined keys:


   HKEY_CLASSES_ROOT
   HKEY_CURRENT_CONFIG
   HKEY_CURRENT_USER
   HKEY_LOCAL_MACHINE
   HKEY_USERS
lpValueName [in, optional]

The registry value to be removed. If this parameter is NULL or an empty string, the value set by the RegSetValue function is removed.

For more information, see Registry Element Size Limits.

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.

Requirements

Minimum supported client

Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Header

Winreg.h (include Windows.h)

Library

Advapi32.lib

DLL

Advapi32.dll

Unicode and ANSI names

RegDeleteValueW (Unicode) and RegDeleteValueA (ANSI)

See also

Registry Functions
Registry Overview
RegSetValueEx

 

 

Send comments about this topic to Microsoft

Build date: 9/7/2011

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Bug in Windows Vista
This function may return ERROR_NO_ACCESS which is a bug in at least Windows Vista:

When lpValueName points to a location within a memory that has been allocated via GlobalAlloc(GMEM_FIXED...) you get this error.
The solution is to copy the String to a local buffer on the stack.