[RESOLVED] RegCreateKeyEx Vista
Hi I wondering if someone can help I Canot seem to get the API Call RegCreateKeyEx to work in Windows Vista, keeps giveing me an error I know the code I am using is working, Becuase I used it a number of times on XP
I included a pice of my code below as reference
is there something I need to do in vista to get RegCreateKeyEx working.
any help will be helpfull.
Code:
'Create the key
If RegCreateKeyEx(m_Key, KeyPath, 0, "", _
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0&, KeyCreate, Dispose) <> ERROR_SUCCESS Then
'Create key faild
CreateKey = 0
Else
'Good result
CreateKey = 1
End If
'Close the key
Call CloseRegKey(KeyCreate)
'Clear up
KeyPath = vbNullString
Re: [RESOLVED] RegCreateKeyEx Vista
It may be useful for others if you told how you solved the problem in case someone finds this thread upon searching.
Re: [RESOLVED] RegCreateKeyEx Vista
You need to elevate your process to run under Administrator permissions.
Re: [RESOLVED] RegCreateKeyEx Vista
I am facing the same registry key creating problem on vista. Can you please post the solutions.
Regards,
bipin maurya
Re: [RESOLVED] RegCreateKeyEx Vista
Welcometo the Forums bipinmaurya.
Quote:
I fixed it by having to set permissions on the Reg key in regedit and giving full control to the path.
Re: [RESOLVED] RegCreateKeyEx Vista
Quote:
I fixed it by having to set permissions on the Reg key in regedit and giving full control to the path.
Isn't there an automatic way to achieve this through VB, rather than manually opening regedit and changing the permissions on a key ?
Re: [RESOLVED] RegCreateKeyEx Vista
Yes, you can use registry APIs to set security permissions on it.
http://allapi.mentalis.org/apilist/RegCreateKeyEx.shtml
Note the lpSecurityDescriptor element of the type.
Re: [RESOLVED] RegCreateKeyEx Vista
Hello, guys!
I tried to use RegCreateKeyEx to create "HKEY_CURRENT_USER" "Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" key. But Vista don't allow it and I get error. I don't get an elevation prompt either.
Why? I'm an admin. HKEY_CURRENT_USER is for user purposes instead of HKEY_LOCAL_MACHINE.
Is there the answer to this question?
Quote:
Originally Posted by
RobDog888
Please can anyone write a simple code by using it?
Re: [RESOLVED] RegCreateKeyEx Vista
I don't have vista to test it on, but try setting dwOptions to REG_OPTION_BACKUP_RESTORE and also lpSecurityDescriptor to SECURITY_ATTRIBUTES
ie:
vb Code:
Dim lngRetval As Long
Dim lngKeyHandle As Long
Dim typSecAtt As SECURITY_ATTRIBUTES
typSecAtt.nLength = Len(typSecAtt)
typSecAtt.lpSecurityDescriptor = 0&
typSecAtt.bInheritHandle = False
RegCreateKeyEx(lngHKey, strSubKey, REG_OPTION_RESERVED, 0&, REG_OPTION_BACKUP_RESTORE, KEY_CREATE_SUB_KEY, typSecAtt, lngKeyHandle, lngRetval)
EDIT:- You will also have to call AdjustTokenPrivileges with "SeRestorePrivilege" and "SeBackupPrivilege" before trying the above code.