what api/s would i need to use do delete whole branches of the regestry tree. :mad:
Printable View
what api/s would i need to use do delete whole branches of the regestry tree. :mad:
You need to use the RegDeleteKey API to delete a registry key and all its subkeys and values.
Here is some sample code on how to use it:
Private Const HKEY_CURRENT_USER = &H80000001
Private Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As Long
Private Sub Form_Load()
' Delete the Test key
Call RegDeleteKey(HKEY_CURRENT_USER, "Software\Test")
End Sub
i've tried the code and i get a return value of 6 instead of 0.
does it have to be done different under nt?
the problem was that i put the const into the module with the private statment, changed it to public and it now works.
i now have the problem that it seems to delete the key but doesnt take effect straight away.
if i colapse the tree in regedit and open it again my test key is still there but when i look at the contents regedit errors with ...
Cannot open Test: Error while opening key.
If you want to see what your Registry API call has done to the registry in RegEdit, it is always best to press F5 to refresh it. RegEdit doesn't automatically update its self like the Windows Explorer does.
;)
soz, should have thaught of that
it fails if the key has subkeys, is there a way around this?
What is the RegDeleteKey API call returning when it fails?
2