|
-
Apr 16th, 2009, 10:33 AM
#1
Thread Starter
Frenzied Member
RegOpenKeyEx + RegDeleteKey on Vista
I'm having an issue with Vista and being able to delete a key from HKCR.
I've been having some trouble for quite some time on this but no matter what I try, it just wont delete the Key.
It works on HKCU & HKLM, but not with HKCR (Hkey_Classes_Root)... I'm logged in as an Admin, Running Vista.
The App has an asInvoker Manifest (tried with requireAdministrator) but same thing..
I've tried KEY_READ, KEY_QUERY_VALUE, KEY_ALL_ACCESS, but it either returns 0 or 5 (Access Denied)
Note: This is the UniCode aware version RegOpenKeyExW
Code:
Private Const KEY_QUERY_VALUE As Long = &H1
Private Const KEY_SET_VALUE As Long = &H2
Private Const KEY_CREATE_SUB_KEY As Long = &H4
Private Const KEY_ENUMERATE_SUB_KEYS As Long = &H8
Private Const KEY_NOTIFY As Long = &H10
Private Const KEY_CREATE_LINK As Long = &H20
Private Const KEY_ALL_ACCESS As Long = &H3F
Private Const KEY_WOW64_64KEY = &H100
Private Const KEY_WOW64_32KEY = &H200
Private Const READ_CONTROL As Long = &H20000
Private Const STANDARD_RIGHTS_REQUIRED As Long = &HF0000
Private Const STANDARD_RIGHTS_READ As Long = READ_CONTROL
Private Const STANDARD_RIGHTS_WRITE As Long = READ_CONTROL
Private Const STANDARD_RIGHTS_EXECUTE As Long = READ_CONTROL
Private Const KEY_READ As Long = STANDARD_RIGHTS_READ Or KEY_QUERY_VALUE Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY
Private Const KEY_WRITE As Long = STANDARD_RIGHTS_WRITE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY
Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExW" _
(ByVal hKey As Long, ByVal lpSubKey As Long, ByVal ulOptions As Long, ByVal samDesired As Long, _
phkResult As Long) As Long
If regDoes_Key_Exist(lngRootKey, strRegKeyPath) Then
m_lngRetVal = RegOpenKeyEx(lngRootKey, StrPtr(strRegKeyPath), 0, KEY_READ, lngKeyHandle)
'MSGBox the result for testing purposes
MsgBox strRegKeyPath, vbOKOnly, m_lngRetVal
If m_lngRetVal = ERROR_SUCCESS Then
m_lngRetVal = RegDeleteKey(lngKeyHandle, StrPtr(strRegKeyName))
If m_lngRetVal = 0 Then regDelete_A_Key = True
m_lngRetVal = RegCloseKey(lngKeyHandle)
End If
End If
_____________________________________________________________________
----If this post has helped you. Please take time to Rate it.
----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.

Tags for this Thread
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
|