home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 6 Unleashed…sional Reference Edition) / Visual_Basic_6_Unleashed_Professional_Reference_Edition_Sams_1999.iso / Source / CHAP29 / 309X3216.TXT < prev    next >
Encoding:
Text File  |  1998-05-05  |  820 b   |  32 lines

  1.  
  2. Private Function RegDelete() As String
  3.  
  4. Dim lonSubkeyHandle As Long
  5. Dim lonStatus As Long
  6.  
  7. ' Use the GetSubkeyHandle function to determine the
  8. ' handle of the subkey given in txtSectionName.
  9. lonSubkeyHandle = GetSubkeyHandle(txtSectionName.Text)
  10. If lonSubkeyHandle = -1 Then
  11.     ' Subkey could not be located.
  12.     RegDelete = "Error - Subkey could not be located"
  13.     Exit Function
  14. End If
  15.  
  16. ' Use the RegDeleteKey API function to delete the
  17. ' key.
  18. lonStatus = RegDeleteValue(lonSubkeyHandle, _
  19.     txtKeyName.Text)
  20. ' Check status of the operation.
  21. If lonStatus <> 0 Then
  22.     RegDelete = "Error - Key could not be deleted"
  23. Else
  24.     RegDelete = "Key deleted sucessfully"
  25. End If
  26.  
  27. ' Close the open subkey with the CloseSubKey
  28. ' function.
  29. lonStatus = CloseSubkey(lonSubkeyHandle)
  30.  
  31. End Function
  32.