Results 1 to 5 of 5

Thread: [RESOLVED] registry problem

  1. #1

    Thread Starter
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,390

    Resolved [RESOLVED] registry problem

    ok ... i have yet another registry problem ...

    i can edit the dword with regedit but when i try to through code it doesnt work - the error code is access denied

    this is in vista and user access control is off

    a cut down ver of the code is as follows:

    Code:
    Const HKEY_LOCAL_MACHINE = &H80000002
    Const KEY_WRITE = &H20006
    Const KEY_WOW64_64KEY = &H100
    Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
    Const ERROR_SUCCESS = 0&
    Const REG_DWORD = 4
    Private Declare Function RegSetValueExA Lib "advapi32.dll" (ByVal hKey As Long, ByVal lpValueName As String, ByVal reserved As Long, ByVal dwType As Long, ByRef lpData As Long, ByVal cbData As Long) As Long
    Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
    
    Public Function Test()
    
    Dim mainKey As Long
    Dim sName As String
        If (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion\MMDevices\Audio\Render\{31ba760e-a198-4aac-8d26-6ea4adf0cfe3}", 0, KEY_WRITE + KEY_WOW64_64KEY, mainKey) = ERROR_SUCCESS) Then
            'try to write data
            If (RegSetValueExA(mainKey, sName, 0, REG_DWORD, 1, 4) = ERROR_SUCCESS) Then
                RegCloseKey mainKey
                'yeap, we did it! ;o)
            Else
                'error :(
            End If
        Else
            'error
        End If
    
    End Function
    it fails on the 1st line with ERROR_SUCCESS in it in the function - as you can see it doesnt go into the if.... returns 5 ...

    any ideas??
    thanks in adv
    kris

  2. #2

    Thread Starter
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,390

    Re: registry problem

    *bump*

  3. #3

  4. #4
    Lively Member
    Join Date
    Oct 2007
    Posts
    126

    Re: registry problem

    Vista has registry control even with User Account Control off. Somewhere on the web I saw someone suggest using Process Monitor to check which registry keys are denying access and edit their permissions using regedt32.exe. Haven't tried it.
    Last edited by MartinLiss; Jul 8th, 2008 at 11:28 PM.

  5. #5

    Thread Starter
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,390

    Re: registry problem

    Quote Originally Posted by Pteranodon
    Vista has registry control even with User Account Control off. Somewhere on the web I saw someone suggest using Process Monitor to check which registry keys are denying access and edit their permissions using regedt32.exe. Haven't tried it.
    that wasnt the problem but i fixed it

    Thanks anyway

    Kris

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