Solved

How to delete a subkey from the registry in VB6

Posted on 2009-07-13
4
254 Views
Last Modified: 2012-05-07
Hello.

I am just starting to get involved in working with the system registry and I have stumbled on a hang up.  I cant figure out how to delete a selected subkey in the registry from a listbox.  For example I need to be able to click on a subkey in a list box and delete it from the registry.  The following is a subkey I want to delete:  

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run\ehTray.exe

0
Comment
Question by:471094
4 Comments
 

Author Comment

by:471094
ID: 24843928
Update---  I just need to be able to delete the ehTray.exe subkey.  Sorry.
0
 
LVL 47

Accepted Solution

by:
Donald Stewart earned 250 total points
ID: 24843964
There's an example here:
http://www.devx.com/vb2themax/Tip/19136 
0
 
LVL 29

Expert Comment

by:nffvrxqgrcfqvvc
ID: 24844863
If you need more help with the registry in the future so experts do not get confused. You can refer to them as Value Name and Value Data. A subkey is confusing because experts looking at your question might think you mean an actual subkey. In this particular question you did give an example which indicates you want to remove a Value Name from the registry but without that example many would assume you need to delete a subkey. :)
0
 
LVL 13

Expert Comment

by:game-master
ID: 24845548

try sumthing like this....

Const HKEY_CLASSES_ROOT = &H80000000
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_USERS = &H80000003
Const HKEY_CURRENT_CONFIG = &H80000005


sComputer = "MyComputer"
sMethod = "DeleteKey"
hTree = HKEY_CURRENT_USER
sKey = "Software\Microsoft\Windows\CurrentVersion\Run\ehTray.exe"


Set oRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}//" & _
        sComputer & "/root/default:StdRegProv")

Set oMethod = oRegistry.Methods_(sMethod)
Set oInParam = oMethod.inParameters.SpawnInstance_()

oInParam.hDefKey = hTree
oInParam.sSubKeyName = sKey

Set oOutParam = oRegistry.ExecMethod_(sMethod, oInParam)




'''''''''''''''''''''
or visit this link for more information....

http://www.serverwatch.com/tutorials/article.php/1476861


game-master
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

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…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

947 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

18 Experts available now in Live!

Get 1:1 Help Now