Solved

How to delete registry keys with subkeys???

Posted on 2001-07-30
6
606 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 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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…
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…

705 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