Witajcie,
Mam problem z funkcją InternetSetOption z biblioteki wininet.dll, którą w VBA deklaruje tak:
Private Declare Function InternetSetOption Lib "wininet.dll" Alias "InternetSetOptionA" (ByVal hInternet As Long, ByVal dwOption As Long, ByVal lpBuffer As Boolean, ByVal dwBufferLength As Integer) As Long
Jest też:
Private Const INTERNET_OPTION_HTTP_DECODING = 65
Następnie w klasie mam taką funkcję:
Private Function OpenUrl(ByVal hSession As Long, ByVal strUrl As String, Optional ByVal bRaiseError = True) As Long
Dim hConnection As Long, lngISetOption As Long, lngBufferLength As Long, lngBuffer As Long, lngFM As Long
Dim strContentEncodingHeader As String
Dim intAddHeaders As Integer
Dim strBufferFM As String * 200
Dim boolDec As Boolean
boolDec = True
lngBufferLength = 1024
'lngBuffer = 100000
' Valid session?
If (hSession = 0) Then
err.Raise 2345345, , "The session is not set!"
Exit Function
End If
' Open Url
hConnection = InternetOpenUrl(hSession, strUrl, vbNullString, ByVal 0&, INTERNET_FLAG_EXISTING_CONNECT Or INTERNET_FLAG_RELOAD, ByVal 0&)
'Gzip
strContentEncodingHeader = "Accept-Encoding: gzip, deflate"
intAddHeaders = HttpAddRequestHeaders(hConnection, strContentEncodingHeader, Len(strContentEncodingHeader), HTTP_ADDREQ_FLAG_REPLACE Or HTTP_ADDREQ_FLAG_ADD)
lngISetOption = InternetSetOption(hConnection, INTERNET_OPTION_HTTP_DECODING, ByVal boolDec, Len(boolDec) + 1)
' Valid file?
If (hConnection = 0) Then
' Error
Call RaiseLastError
' Exit
Exit Function
End If
' Get the value
OpenUrl = hConnection
End Function
Funkcja HttpAddRequestHeaders
zwraca 1
, funkcja InternetSetOption
zwraca 0
. Kod błędu: 87
, parametr jest niepoprawny.
Co może być przyczyną błędu?
dodanie znaczników <code class="vbnet"> - furious programming