RegDeleteValue Function

Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long

Platforms: Win 95/98, Win NT

RegDeleteValue deletes a value stored under a specified key in the registry. This function only works with values stored; it cannot delete subkeys. The value can of course be of any registry data type. The function returns 0 if successful, or a non-zero error code if an error occured.

hKey
A handle to the open registry key which contains the value to delete.
lpValueName
The name of the value to delete.

Example:

' Delete the value "SplashScreen" under the hypothetical registry key
' "HKEY_LOCAL_MACHINE\Software\MyProgram\Config".  Note how error conditions are checked.
Dim hkey As Long  ' handle to the open registry key
Dim retval As Long  ' return value

' First, open up the registry key which holds the value to delete.
retval = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\MyProgram\Config", 0, KEY_ALL_ACCESS, hkey)
If retval = 0 Then  ' successfully opened registry key
  ' Now delete the desired value from the key.
  retval = RegDeleteValue(hkey, "SplashScreen")  ' if it existed, it is now deleted
  ' Note that we only have to close the registry key if it was successfully opened.
  retval = RegCloseKey
End If

See Also: RegDeleteKey, RegQueryValueEx, RegSetValueEx
Category: Registry

Go back to the alphabetical Function listing.
Go back to the Reference section index.


This page is copyright © 2000 Paul Kuliniewicz. Copyright Information.
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/r/regdeletevalue.html