nil092297
asked on
Accessing the registry from VBA!?
hi I tried to access the registry from VBA. I used the reg funktions from the "advapi32.dll".
the code:
Declare Function RegOpenKeyExA Biblio "ADVAPI32" _
(ByVal hkey As Long; ByVal lpSubKey As String; _
ByVal ulOptions As Long; ByVal samDesired As Long; phkResult As Long) _
As Long
Declare Function RegQueryValueExA Biblio "ADVAPI32" _
ByVal hkey As Long; ByVal lpValueName As String; _
ByVal lpReserved As Long; lpType As Long; ByVal lpData As String; _
phkResult As Long) As Long
Declare Function RegCloseKey Biblio "ADVAPI32" _
ByVal hkey As Long) As Long
Dim HKEY_LOCAL_MACHINE As Long
Dim KEY_ALL_ACCESS Als Lang
Dim phkErg As Long
Dim TypVar As Long
Dim langVar As Long
Dim Ergebnis2 As String
'Evaluated from VC++:
HKEY_LOCAL_MACHINE = -2147483646
KEY_ALL_ACCESS = 983103
Erfolg = RegOpenKeyExA(HKEY_LOCAL_M ACHINE; "SOFTWARE\HelloWorld\"; _
0; KEY_ALL_ACCESS; phkErg)
Erfolg = RegQueryValueExA(phkErg; "Kanal" & I; 0; TypVar; Ergebnis2; langVar)
Erfolg = RegCloseKey(phkErg)
The key was opened correctly (returns 0). Also the RegQueryValueEx returns fine (returns 0). The langVar (parameter six) is correct returned. The TypVar parameter (parameter four) is correct returned. Only the Value is empty!!!!!!!!!
comments?
the code:
Declare Function RegOpenKeyExA Biblio "ADVAPI32" _
(ByVal hkey As Long; ByVal lpSubKey As String; _
ByVal ulOptions As Long; ByVal samDesired As Long; phkResult As Long) _
As Long
Declare Function RegQueryValueExA Biblio "ADVAPI32" _
ByVal hkey As Long; ByVal lpValueName As String; _
ByVal lpReserved As Long; lpType As Long; ByVal lpData As String; _
phkResult As Long) As Long
Declare Function RegCloseKey Biblio "ADVAPI32" _
ByVal hkey As Long) As Long
Dim HKEY_LOCAL_MACHINE As Long
Dim KEY_ALL_ACCESS Als Lang
Dim phkErg As Long
Dim TypVar As Long
Dim langVar As Long
Dim Ergebnis2 As String
'Evaluated from VC++:
HKEY_LOCAL_MACHINE = -2147483646
KEY_ALL_ACCESS = 983103
Erfolg = RegOpenKeyExA(HKEY_LOCAL_M
0; KEY_ALL_ACCESS; phkErg)
Erfolg = RegQueryValueExA(phkErg; "Kanal" & I; 0; TypVar; Ergebnis2; langVar)
Erfolg = RegCloseKey(phkErg)
The key was opened correctly (returns 0). Also the RegQueryValueEx returns fine (returns 0). The langVar (parameter six) is correct returned. The TypVar parameter (parameter four) is correct returned. Only the Value is empty!!!!!!!!!
comments?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER