GPF in AdvApi32.Dll - Help Anyone? 
Author Message
 GPF in AdvApi32.Dll - Help Anyone?

Here is my problem... I am calling the RegQueryValueEx Function to get the
value of a string from the Registry. When I call the function I get a GPF
in AdvApi32.Dll... Any help.. Here is my calling function.

Public Function RegStrGet(hKey As Long, lpSubKey As String, lpValueName As
String) As String
  Dim lpReserved As Long
  Dim lpType As Long
  Dim lpData As String
  Dim lpcbData As Long
  Dim fSuccess As Long
  lpcbData = 40
  hKey = RegKeyOpen(hKey, lpSubKey)
  fSuccess = RegQueryValueEx(hKey, lpValueName, lpReserved, lpType, lpData,
lpcbData)
  If fSuccess = ERROR_SUCCESS Then
    RegStrGet = lpData
  Else
    RegStrGet = "RegStrGet_ERROR: " & fSuccess
  End If
  fSuccess = RegCloseKey(hKey)
End Function



Sun, 12 Dec 1999 03:00:00 GMT  
 GPF in AdvApi32.Dll - Help Anyone?



Quote:
> Here is my problem... I am calling the RegQueryValueEx Function to get
the
> value of a string from the Registry. When I call the function I get a GPF
> in AdvApi32.Dll... Any help.. Here is my calling function.

> Public Function RegStrGet(hKey As Long, lpSubKey As String, lpValueName
As
> String) As String
>   Dim lpReserved As Long
>   Dim lpType As Long
>   Dim lpData As String
>   Dim lpcbData As Long
>   Dim fSuccess As Long
>   lpcbData = 40
>   hKey = RegKeyOpen(hKey, lpSubKey)
>   fSuccess = RegQueryValueEx(hKey, lpValueName, lpReserved, lpType,
lpData,
> lpcbData)
>   If fSuccess = ERROR_SUCCESS Then
>     RegStrGet = lpData
>   Else
>     RegStrGet = "RegStrGet_ERROR: " & fSuccess
>   End If
>   fSuccess = RegCloseKey(hKey)
> End Function

A friend of mine (sorry Christophe), has write this similar function and it
works fine :

Private Declare Function API_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
Private Declare Function API_RegQueryValueEx Lib "advapi32.dll" Alias
"RegQueryValueExA" (ByVal hkey As Long, ByVal lpValueName As String, ByVal
lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As
Long
Private Declare Function API_RegSetValueEx Lib "advapi32.dll" Alias
"RegSetValueExA" (ByVal hkey As Long, ByVal lpValueName As String, ByVal
Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As
Long) As Long

Private Function fRegGetString(hInkey As Long, ByVal strSubKey As String,
ByVal strValName As String, Default As Variant) As Variant
Dim phkResult As Long
Dim strValeur As String * 256
Dim lngValeur As Long
Dim dummy As Long
    dummy = API_RegOpenKeyEx(hInkey, strSubKey, 0, KEY_ALL_ACCESS,
phkResult)
    If dummy = 0 Then
        lngValeur = 256
        dummy = API_RegQueryValueEx(phkResult, strValName, 0, REG_SZ, ByVal
strValeur, lngValeur)
        If dummy = 0 Then
            fRegGetString = Left(strValeur, Len(Trim(strValeur)) - 1)
        Else
            fRegGetString = Default
            Err = dummy
        End If
    End If
End Function

--

________________________________
Stphane WUCHER - Noisy - FRANCE



Sun, 12 Dec 1999 03:00:00 GMT  
 GPF in AdvApi32.Dll - Help Anyone?

Quote:

> Here is my problem... I am calling the RegQueryValueEx Function to get the
> value of a string from the Registry. When I call the function I get a GPF
> in AdvApi32.Dll... Any help.. Here is my calling function.
> Public Function RegStrGet(hKey As Long, lpSubKey As String, lpValueName As
> String) As String
>   Dim lpReserved As Long
>   Dim lpType As Long
>   Dim lpData As String
>   Dim lpcbData As Long
>   Dim fSuccess As Long
>   lpcbData = 40
>   hKey = RegKeyOpen(hKey, lpSubKey)
>   fSuccess = RegQueryValueEx(hKey, lpValueName, lpReserved, lpType, lpData, lpcbData)
>   If fSuccess = ERROR_SUCCESS Then
>     RegStrGet = lpData
>   Else
>     RegStrGet = "RegStrGet_ERROR: " & fSuccess
>   End If
>   fSuccess = RegCloseKey(hKey)
> End Function

Mmmm. Yes. Not much to go on. Would you like to show us your declarations for
RegKeyOpen, RegQueryValueEx, RegCloseKey? Or are you positive they're correct?
Have you stepped through this with your de{*filter*}? From the above explanation,
I gather that it all goes pear shaped on the fSuccess = RegQueryValueEx line.

--

Onyx Internet -- Exchange Square -- Middlesbrough -- Cleveland -- TS1 1DE
.....BB..74..A4..EF..03..F8..44..C1..F3..75..FE..C6..7E..F9..6E..43......
All Unsolicited Commercial Email is forwarded to appropriate authorities.
No business will be done with its transmitter for a minimum of six years.



Mon, 13 Dec 1999 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. GPF in AdvApi32.Dll - Help Anyone?

2. data1.refresh causes GPF in MSJT3032.DLL...anyone?`

3. data1.refresh causes GPF in MSJT3032.DLL...anyone?`

4. data1.refresh causes GPF in MSJT3032.DLL...anyone?

5. Help using advapi32.dll

6. Asymmetric encryption (VERY URGENT PLS HELP) advapi32.dll

7. Help Me Please ADVAPI32.DLL The RegSaveKey Function

8. Can't find DLL entry point OpenEventLog in advapi32.dll

9. Large UDT causes GPF - Can anyone help?!

10. GPF in AdvApi32.Dll - Help? <Read This One>

11. GPF in AdvApi32.Dll - Help? <Read This One>

12. Advapi32.dll

 

 
Powered by phpBB® Forum Software