[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