[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1428
  • Last Modified:

Need VB6 API function to delete a registry key and all of it's subkeys and values

I need some code examples to delete a registry key and all of it's subkeys and values. I have found numerous examples on how to delete an empty key using RegDeleteKey, but no working examples on how to delete a key with subkeys and values. The example must use API calls, specifically RegDeleteKeyEx, not RegDeleteKey so that I can set my samDesired to KEY_WOW64_64KEY and use the alternate registry view and access 64 bit keys from a 32 bit app. I have had no problem finding code for querying , enumerating and creating 64 bit key/values, not sure why deleting a key is so difficult.
0
advcom
Asked:
advcom
  • 2
  • 2
1 Solution
 
d3nCommented:
0
 
advcomAuthor Commented:
Thanks for the reply, I had looked at that example already. It would only be able to delete 32 bit subkeys. From what I have read, you have to use RegDeleteKeyEx in order to delete 64 bit keys and it's syntax is different than RegDeleteKey.
0
 
ArkCommented:
DON'T TRY IT!
Change reg path first!
Private Sub Command1_Click()
    Dim Str As String
    Str = "REG DELETE " & Chr(34) & "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" & CHR(34) & " /f /reg:64"
    Shell Str, vbNormalFocus
End Sub

Open in new window

0
 
advcomAuthor Commented:
That was beautiful. It worked perfectly. I actually ran REG /? on a 7 command prompt before posting this question, but it did not show the 64 bit option. Thanks much
0
 
ArkCommented:
Tsss... This is M$ Top Secret :) I couldn't find this anywhere in MSDN
Here it is (not directly about this switch, but if read between strings...):
http://kbalertz.com/948698/cannot-utility-access-registry-computer-computer-running-version-Windows-Server.aspx
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now