|
-
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.

-
Apr 17th, 2009, 07:24 AM
#2
Thread Starter
Frenzied Member
Re: RegOpenKeyEx + RegDeleteKey on Vista
_____________________________________________________________________
----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.

-
Jun 15th, 2009, 11:57 AM
#3
Thread Starter
Frenzied Member
Re: RegOpenKeyEx + RegDeleteKey on Vista
*Quite an old thread, but still haven't figured this one out...*
Any Ideas?
*BUMP*
Last edited by some1uk03; Aug 5th, 2009 at 11:01 AM.
_____________________________________________________________________
----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.

-
Aug 5th, 2009, 11:02 AM
#4
Thread Starter
Frenzied Member
Re: RegOpenKeyEx + RegDeleteKey on Vista
*BUMP*
This is almost a few months old. Someone must have any clues?
_____________________________________________________________________
----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.

-
Aug 5th, 2009, 12:51 PM
#5
Re: RegOpenKeyEx + RegDeleteKey on Vista
Do you have the relevant permissions to access this subkey? Sometimes Admin privileges aren't good enough. In regedit, right-click on the subkey and click "Permissions".
In any case you should use KEY_SET_VALUE.
-
Aug 5th, 2009, 12:57 PM
#6
Re: RegOpenKeyEx + RegDeleteKey on Vista
i googled this: "HKCR vista" and got a lot of results
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Aug 5th, 2009, 01:15 PM
#7
Lively Member
Re: RegOpenKeyEx + RegDeleteKey on Vista
From what I've read @ http://www.vistax64.com/vista-accoun...rmissions.html :
Note that HKEY_CLASSES_ROOT is HKEY_LOCAL_MACHINE\Software\Classes and
HKEY_CURRENT_USER\Software\Classes combined together, with entries in
HKCU taking precedence.
If it's combined, I can only guess that it's read-only and you should try to one of those other two paths.
If a thread is solved, please click on Thread Tools / Mark Thread Resolved .
If someone helped you very good, consider rating his post by clicking the icon under his name.
-
Aug 6th, 2009, 05:59 AM
#8
Thread Starter
Frenzied Member
Re: RegOpenKeyEx + RegDeleteKey on Vista
Thanks for the suggestions guys...
The whole process here is that I'm doing a registry utility which scans & fixes corrupt paths etc...
 Originally Posted by schoolbusdriver
Do you have the relevant permissions to access this subkey? Sometimes Admin privileges aren't good enough. In regedit, right-click on the subkey and click "Permissions".
In any case you should use KEY_SET_VALUE.
Manually right-clicking in regedit is not an option really, because I can't expect the end user to manually go and do this.
Garrcomm
How would you check if they're combined or not?
I'm thinking, shall I scan
HKEY_CURRENT_USER\Software\Classes instead or
HKEY_LOCAL_MACHINE\Software\Classes instead or
HKCR
_____________________________________________________________________
----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.

-
Aug 6th, 2009, 10:06 AM
#9
Re: RegOpenKeyEx + RegDeleteKey on Vista
 Originally Posted by some1uk03
Manually right-clicking in regedit is not an option really, because I can't expect the end user to manually go and do this.
Obviously. However, if YOU can determine it's a permissions issue, you may be able to write code to compensate.
-
Aug 6th, 2009, 01:08 PM
#10
Thread Starter
Frenzied Member
Re: RegOpenKeyEx + RegDeleteKey on Vista
That link seems quite interesting actually. It says:
"If you write keys to a key under HKEY_CLASSES_ROOT, the system stores
the information under HKEY_LOCAL_MACHINE\Software\Classes. If you write
values to a key under HKEY_CLASSES_ROOT, and the key already exists
under HKEY_CURRENT_USER\Software\Classes, the system will store the
information there instead of under HKEY_LOCAL_MACHINE\Software\Classes."
So, in theory, I should be scanning in HKEY_CURRENT_USER\Software\Classes in Vista & Windows 7, but HKCU in XP
------------------EDIT-------------------
Actually no, my theory is corrupt. It is still HKCR that needs to be scanned!
Is there a way to check the security permissions of a key in VB? If that's possible, then I think problem sorted!
Last edited by some1uk03; Aug 6th, 2009 at 02:16 PM.
_____________________________________________________________________
----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.

-
Aug 7th, 2009, 08:51 AM
#11
Thread Starter
Frenzied Member
-
Aug 9th, 2009, 03:05 PM
#12
Thread Starter
Frenzied Member
Re: RegOpenKeyEx + RegDeleteKey on Vista
_____________________________________________________________________
----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
|