• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 656
  • Last Modified:

How to delete registry keys with subkeys???

The RegDeleteKey API only works for keys that do not have subkeys.  How do I delete the entire branch even though it has subkeys beneath it???  Anyone?

M
0
msejfovic
Asked:
msejfovic
1 Solution
 
jmerrittCommented:
regedit...
0
 
msejfovicAuthor Commented:
I meant through an API call
0
 
DennisBorgCommented:
>The RegDeleteKey API only works for keys that do not have subkeys.

This is true for WinNT and Win2K. If you have Win95/ Win98, then it also deletes all subkeys.

For WinNT and Win2K, you'll want to use the SHDeleteKey Win API function, from Version 4.71 and later of Shlwapi.dll

I haven't been able to find the declaration for it to use in VB, but I imagine it is one of the following:


Public Declare Function SHDeleteKey Lib "shlwapi.dll" Alias "SHDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As Long

OR

Public Declare Function SHDeleteKey Lib "shlwapi.dll" (ByVal hKey As Long, ByVal lpSubKey As String) As Long



Perhaps someone else can confirm the declaration statement for this function.


-Dennis Borg
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
TimCotteeCommented:
Dennis I believe it should be Public Declare Function SHDeleteKey Lib "shlwapi.dll" Alias "SHDeleteKeyA" (ByVal hKey As Long, ByVal
lpSubKey As String) As Long
Public Const HKEY_LOCAL_MACHINE = &H80000002

Used as
Dim Return As Long
Return = SHDeleteKey (HKEY_LOCAL_MACHINE,"\Software\Microsoft\Etc\Etc" & Chr(0))

I have not used it myself but give it a try.

0
 
DanRollinsCommented:
Hi msejfovic,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept DennisBorg@idg's comment(s) as an answer.

msejfovic, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 
Computer101Commented:
Comment from expert accepted as answer

Computer101
E-E Moderator
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now