How to delete a registry key ? 
Author Message
 How to delete a registry key ?

Folks,

I now how to create, set any registry keys (not necessarily only those in
"VB and VBA Programming"), but I don't know (yet) how to delete any key from
the registry...
Any idea ?

Cheers /jerome



Fri, 06 Oct 2000 03:00:00 GMT  
 How to delete a registry key ?

Quote:

>I now how to create, set any registry keys (not necessarily only those in
>"VB and VBA Programming"), but I don't know (yet) how to delete any key
from
>the registry...
>Any idea ?

From the API Viewer:

Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA"
(ByVal hKey As Long, ByVal lpSubKey As String) As Long

Caveat: You *might* want to check the parameter declarations, the API viewer
has a few 'misdeclared' ones... Also if it doesn't work, try changing ByVal
to ByRef...

hKey being one of the following base keys:
Public Const HKEY_CLASSES_ROOT = &H80000000
Public Const HKEY_CURRENT_CONFIG = &H80000005
Public Const HKEY_CURRENT_USER = &H80000001
Public Const HKEY_DYN_DATA = &H80000006
Public Const HKEY_LOCAL_MACHINE = &H80000002
Public Const HKEY_PERFORMANCE_DATA = &H80000004
Public Const HKEY_USERS = &H80000003

lpSubKey is a sub-key of the base key.

Don't forget to use \\ instead of \ for your registry tree (e.g.
"SOFTWARE\\MyApp\\Default"). It will cause some kind of error if you don't
(I haven't tried yet, though).

--
My e-mail address may have 2 bugs in it; deBUG to reply.

Damit Senanayake
Damit's Home; http://web.singnet.com.sg/~apesena/
ICQ UIN: 6930718

"It's one small step for man, one giant leap for mankind." -- Neil Armstrong



Fri, 06 Oct 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Deleting Registry key and sub-keys?

2. Deleting a registry Key

3. How to Delete Registry Key

4. Need API to delete registry key [Q]

5. stopping the registry from deleting an entry in the RunOnce key

6. How do I delete Registry Keys?

7. Deleting registry key via vbscript

8. Delete registry key from VBS?

9. Deleting Registry Keys

10. Delete Registry key

11. Newbie: deleting registry keys

12. How to delete Registry Keys in VB5

 

 
Powered by phpBB® Forum Software