Results 1 to 10 of 10

Thread: [RESOLVED] RegCreateKeyEx Vista

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    UK
    Posts
    417

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

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    UK
    Posts
    417

    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.

  3. #3
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    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.

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  5. #5
    New Member
    Join Date
    Jan 2009
    Posts
    1

    Re: [RESOLVED] RegCreateKeyEx Vista

    I am facing the same registry key creating problem on vista. Can you please post the solutions.

    Regards,
    bipin maurya

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  7. #7
    Frenzied Member some1uk03's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    1,675

    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.



  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  9. #9
    Addicted Member
    Join Date
    Feb 2006
    Posts
    133

    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 View Post
    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.
    Please can anyone write a simple code by using it?
    Last edited by pantalone; Apr 15th, 2009 at 06:14 PM.

  10. #10
    Fanatic Member schoolbusdriver's Avatar
    Join Date
    Jan 2006
    Location
    O'er yonder
    Posts
    1,020

    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:
    1. Dim lngRetval     As Long
    2. Dim lngKeyHandle  As Long
    3. Dim typSecAtt     As SECURITY_ATTRIBUTES
    4.  
    5. typSecAtt.nLength = Len(typSecAtt)
    6. typSecAtt.lpSecurityDescriptor = 0&
    7. typSecAtt.bInheritHandle = False
    8.  
    9. 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
  •  



Click Here to Expand Forum to Full Width