?
Solved

How to delete registry keys with subkeys???

Posted on 2001-07-30
6
Medium Priority
?
622 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 20 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month9 days, 17 hours left to enroll

762 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