Windows API Guide: PolyBezierTo Function


Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As Long

Platforms

  • Windows 95: Supported.
  • Windows 98: Supported.
  • Windows NT: Requires Windows NT 3.1 or later.
  • Windows 2000: Supported.
  • Windows CE: Requires Windows CE 1.0 or later.

Description & Usage

RegDeleteKey deletes a key from the registry, along with any values it may contain. Windows NT, 2000: The function will fail if there are any subkeys under the key to delete. Windows 95, 98: The function will delete any subkeys under the key to be deleted, instead of failing.

Return Value

If successful, the function returns zero. If an error occured, the function returns a nonzero error code.

Visual Basic-Specific Issues

None.

Parameters

hKey
Specifies an existing registry key that the key to delete is under. This is either a handle to an open registry key or one of the following flags that identify a registry base key. (The base key flags are named identically to the base keys they specify.)
HKEY_CLASSES_ROOT
HKEY_CURRENT_CONFIG
HKEY_CURRENT_USER
HKEY_DYN_DATA (Windows 95, 98 only)
HKEY_LOCAL_MACHINE
HKEY_PERFORMANCE_DATA (Windows NT, 2000 only)
HKEY_USERS
lpSubKey
The name of the subkey under hKey to delete.

Constant Definitions

Const HKEY_CLASSES_ROOT = &H80000000 Const HKEY_CURRENT_CONFIG = &H80000005 Const HKEY_CURRENT_USER = &H80000001 Const HKEY_DYN_DATA = &H80000006 Const HKEY_LOCAL_MACHINE = &H80000002 Const HKEY_PERFORMANCE_DATA = &H80000004 Const HKEY_USERS = &H80000003

Example:

Attempt to delete the registry key "HKEY_LOCAL_MACHINE\Software\MyProgram\Config" when the user clicks button Command1. (Of course, typically you would never give the user an option like this, but this is just a simple example.) Depending on your Windows platform, this function may fail if there are any subkeys under this key. To run this example, you first need to place a command button named Command1 on a form window.

' This code is licensed according to the terms and conditions listed here. ' Declarations and such needed for the example: ' (Copy them to the (declarations) section of a module.) Public Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, _ ByVal lpSubKey As String) As Long Public Const HKEY_LOCAL_MACHINE = &H80000002 Private Sub Command1_Click() Dim retval As Long  ' return value ' Attempt to delete the desired registry key. retval = RegDeleteKey(HKEY_LOCAL_MACHINE, "Software\MyProgram\Config") If retval <> 0 Then Debug.Print "Delete operation failed.  The key may have subkeys and/or values under it." Debug.Print "Of course, the key might just not exist at all." Else Debug.Print "Deletion successful." End If End Sub

See Also

RegCreateKeyEx, RegDeleteValue

Category

Registry

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


Last Modified: September 24, 2000
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/regdeletekey.html



Windows API Guide
Windows API Guide - Reference - Volume 1: Version 3.0 For the MS-DOS and PC-DOS Operating Systems
ISBN: B001V0KQIY
EAN: N/A
Year: 1998
Pages: 610

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net