
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