EDN Admin
Well-known member
Hi there,
Im 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,
<span class="comment-copy like it was successfully deleted the key, but the key is still remains there...
<pre class="prettyprint lang-vb 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[/code]
<br/>
Just to mention I CAN WRITE, READ, DELETE VALUES to/from 64-bit registry, but I cant DELETE a key...everything working great except that DELETE KEY function!
Please help me out!
View the full article
Im 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,
<span class="comment-copy like it was successfully deleted the key, but the key is still remains there...
<pre class="prettyprint lang-vb 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[/code]
<br/>
Just to mention I CAN WRITE, READ, DELETE VALUES to/from 64-bit registry, but I cant DELETE a key...everything working great except that DELETE KEY function!
Please help me out!
View the full article