Solved

How to delete registry keys with subkeys???

Posted on 2001-07-30
6
556 Views
Last Modified: 2007-12-19
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
Comment
Question by:msejfovic
6 Comments
 
LVL 1

Expert Comment

by:jmerritt
ID: 6335722
regedit...
0
 

Author Comment

by:msejfovic
ID: 6335731
I meant through an API call
0
 
LVL 8

Accepted Solution

by:
DennisBorg earned 5 total points
ID: 6335861
>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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 43

Expert Comment

by:TimCottee
ID: 6336097
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
 
LVL 49

Expert Comment

by:DanRollins
ID: 7161675
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
 
LVL 1

Expert Comment

by:Computer101
ID: 7182446
Comment from expert accepted as answer

Computer101
E-E Moderator
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB6 add a minute to the date time value 8 61
Saving history changes to sub form 4 36
Hide vba in gp 7 82
VB6 ListBox Question 4 32
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

28 Experts available now in Live!

Get 1:1 Help Now