I'm trying to delete registry key from Windows 7 64-bit registry, defined everything fine, the API wont delete registry key, but the function returns me 0 to ERROR_SUCCESS and TRUE value, like it was successfully deleted the key, but the key is still remains there...
Option Explicit Private Const ERROR_SUCCESS = 0& Public Enum HKEY_Type HKEY_CLASSES_ROOT = &H80000000 HKEY_CURRENT_USER = &H80000001 HKEY_LOCAL_MACHINE = &H80000002 HKEY_USERS = &H80000003 HKEY_PERFORMANCE_DATA = &H80000004 HKEY_CURRENT_CONFIG = &H80000005 HKEY_DYN_DATA = &H80000006 End Enum Private Const KEY_ALL_ACCESS = &H3F Private Const KEY_WOW64_64KEY As Long = &H100& Private Declare Function RegDeleteKeyEx Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal samDesired As Long, ByVal Reserved As Long) As Long Public Function DeleteKey(ByVal RootKey As HKEY_Type, ByVal SubKey As String) As Boolean On Error Resume Next Dim lgRet As Long lgRet = RegDeleteKeyEx(RootKey, SubKey, KEY_ALL_ACCESS Or KEY_WOW64_64KEY, 0&) If lgRet = ERROR_SUCCESS Then DeleteKey = True Else DeleteKey = False End If Exit Function End Function
I wish to delete custom created key by me, calling:
Dim blRet As Boolean blRet = DeleteKey(HKEY_LOCAL_MACHINE, "Software\Test By Me")
Just to mention I CAN WRITE, READ, DELETE VALUES to/from 64-bit registry, but I can't DELETE a key...everything working great except that DELETE KEY function!
p.s. UAC is disabled, so virtualisation not an issue here.
Thanks for your time and for your help!