|
-
Nov 5th, 2008, 09:32 AM
#1
Thread Starter
Hyperactive Member
[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
When your dreams come true.
On error resume pulling hair out.
-
Nov 5th, 2008, 01:35 PM
#2
Thread Starter
Hyperactive Member
Re: RegCreateKeyEx Vista
Thanks for anyone at looking at this, but I now fixed the problum.
I fixed it by having to set permissions on the Reg key in regedit and giving full control to the path.
Thanks agian.
Last edited by dreamvb; Nov 5th, 2008 at 04:29 PM.
When your dreams come true.
On error resume pulling hair out.
-
Nov 5th, 2008, 01:54 PM
#3
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.
-
Nov 6th, 2008, 10:14 PM
#4
Re: [RESOLVED] RegCreateKeyEx Vista
You need to elevate your process to run under Administrator permissions.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 2nd, 2009, 06:25 AM
#5
New Member
Re: [RESOLVED] RegCreateKeyEx Vista
I am facing the same registry key creating problem on vista. Can you please post the solutions.
Regards,
bipin maurya
-
Jan 8th, 2009, 03:22 AM
#6
Re: [RESOLVED] RegCreateKeyEx Vista
Welcometo the Forums bipinmaurya.
I fixed it by having to set permissions on the Reg key in regedit and giving full control to the path.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 8th, 2009, 03:54 AM
#7
Re: [RESOLVED] RegCreateKeyEx Vista
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 ?
_____________________________________________________________________
----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.

-
Jan 8th, 2009, 04:29 AM
#8
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.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Apr 15th, 2009, 04:59 PM
#9
Addicted Member
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?
 Originally Posted by RobDog888
Please can anyone write a simple code by using it?
Last edited by pantalone; Apr 15th, 2009 at 06:14 PM.
-
Apr 16th, 2009, 03:54 AM
#10
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.
Last edited by schoolbusdriver; Apr 16th, 2009 at 04:05 AM.
Reason: Forgot about AdjustTokenPrivileges
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
|