|
-
Apr 17th, 2001, 05:43 AM
#1
Thread Starter
Addicted Member
what api/s would i need to use do delete whole branches of the regestry tree.
-
Apr 17th, 2001, 06:12 AM
#2
Addicted Member
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
-
Apr 17th, 2001, 06:44 AM
#3
Thread Starter
Addicted Member
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?
-
Apr 17th, 2001, 07:02 AM
#4
Thread Starter
Addicted Member
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.
-
Apr 17th, 2001, 07:07 AM
#5
Addicted Member
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.
-
Apr 17th, 2001, 07:09 AM
#6
Thread Starter
Addicted Member
soz, should have thaught of that
-
Apr 17th, 2001, 07:39 AM
#7
Thread Starter
Addicted Member
it fails if the key has subkeys, is there a way around this?
-
Apr 18th, 2001, 02:24 AM
#8
Addicted Member
What is the RegDeleteKey API call returning when it fails?
-
Apr 18th, 2001, 02:42 AM
#9
Thread Starter
Addicted Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|