?
Solved

How to delete a subkey from the registry in VB6

Posted on 2009-07-13
4
Medium Priority
?
259 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
[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
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 750 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

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

771 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