vbkann
asked on
Http - wininet problem
I use a class module to recieve files off the internet. The files that i am recieving are always changing the data contained within them.
I am recieving .txt files and values returned by .cgi files.
However, the values that i get returned to me in code are values from the cache and not what the files contain.
I use the INTERNET_FLAG_RELOAD constant in the following code but i still get values returned that are not correct:
hHttpOpenRequest = HttpOpenRequest(hInternetC onnect, "GET", UrlAddress, "HTTP/1.0", vbNullString, 0, INTERNET_FLAG_RELOAD, 0)
What is going wrong and how can i fix it please.
thanks
I am recieving .txt files and values returned by .cgi files.
However, the values that i get returned to me in code are values from the cache and not what the files contain.
I use the INTERNET_FLAG_RELOAD constant in the following code but i still get values returned that are not correct:
hHttpOpenRequest = HttpOpenRequest(hInternetC
What is going wrong and how can i fix it please.
thanks
ASKER
Is there a specific piece of code there that i should look at? If so could you give me the url to its page as i cannot find anything there to help me really. Sorry
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
try also internet_flag_pragma_nocac he
Hi vbkann,
I'm sorry, the links not about HTTP using WinInet API, but using Winsock.
Who knows, you want to try winsock
http://www.vbip.com/winsock/winsock_http_01.asp
regards
danny
I'm sorry, the links not about HTTP using WinInet API, but using Winsock.
Who knows, you want to try winsock
http://www.vbip.com/winsock/winsock_http_01.asp
regards
danny
I am not sure, but I think the the reload only works with the InternetOpenUrl call. You will need to rem out some of the error stuff below to get this to work, but it is very solid.
Here is the call to open the internet session:
hInternetSession = InternetOpen(sUserAgent, INTERNET_OPEN_TYPE_PRECONF IG, vbNullString, vbNullString, 0)
Here is the function:
Public Function ReadUrl(ByVal sURL As String, Optional vFileName As Variant) As Boolean
Dim sReadBuffer As String * 2048 ' bytes to read from call to InternetReadFile
Dim lNumberOfBytesRead As Long ' bytes read from call to InternetReadFile
Dim lTotalBytesRead As Long ' total bytes read
Dim bDoLoop As Boolean ' return value from InternetReadFile
Dim bReadInternetFile As Boolean
Dim bWriteToFile As Boolean
On Error GoTo errReadUrl
Screen.MousePointer = vbHourglass
SetStatus "Opening: " & sURL
If Not IsMissing(vFileName) Then
Dim iFileNum As Integer
iFileNum = FreeFile
Open CStr(vFileName) For Binary As iFileNum
bWriteToFile = True
End If
Dim dwFlags As Long
dwFlags = INTERNET_FLAG_EXISITING_CO NNECT
dwFlags = dwFlags + INTERNET_FLAG_RELOAD + INTERNET_FLAG_NO_COOKIES
hUrlFile = InternetOpenUrl(hInternetS ession, sURL, vbNullString, 0, dwFlags, 0)
If CBool(hUrlFile) Then
sContents = scBlankStr
bDoLoop = True
While bDoLoop
sReadBuffer = scBlankStr
bDoLoop = InternetReadFile(hUrlFile, sReadBuffer, Len(sReadBuffer), lNumberOfBytesRead)
If Not CBool(bDoLoop) Then CheckError
lTotalBytesRead = lTotalBytesRead + lNumberOfBytesRead
SetStatus "Reading Url: " & CStr(lTotalBytesRead) & " bytes read"
If CBool(lNumberOfBytesRead) Then
If bWriteToFile Then
Put #iFileNum, , sReadBuffer
Else
sContents = sContents & Left$(sReadBuffer, lNumberOfBytesRead)
End If
Else
bDoLoop = False
bReadInternetFile = True
End If
Wend
InternetCloseHandle (hUrlFile)
If bWriteToFile Then Close
ReadUrl = True
Else
CheckError
End If
SetStatus "Ready"
Screen.MousePointer = vbDefault
Exit Function
errReadUrl:
sLastError = Error$(Err)
Screen.MousePointer = vbDefault
Exit Function
End Function
Here is the call to open the internet session:
hInternetSession = InternetOpen(sUserAgent, INTERNET_OPEN_TYPE_PRECONF
Here is the function:
Public Function ReadUrl(ByVal sURL As String, Optional vFileName As Variant) As Boolean
Dim sReadBuffer As String * 2048 ' bytes to read from call to InternetReadFile
Dim lNumberOfBytesRead As Long ' bytes read from call to InternetReadFile
Dim lTotalBytesRead As Long ' total bytes read
Dim bDoLoop As Boolean ' return value from InternetReadFile
Dim bReadInternetFile As Boolean
Dim bWriteToFile As Boolean
On Error GoTo errReadUrl
Screen.MousePointer = vbHourglass
SetStatus "Opening: " & sURL
If Not IsMissing(vFileName) Then
Dim iFileNum As Integer
iFileNum = FreeFile
Open CStr(vFileName) For Binary As iFileNum
bWriteToFile = True
End If
Dim dwFlags As Long
dwFlags = INTERNET_FLAG_EXISITING_CO
dwFlags = dwFlags + INTERNET_FLAG_RELOAD + INTERNET_FLAG_NO_COOKIES
hUrlFile = InternetOpenUrl(hInternetS
If CBool(hUrlFile) Then
sContents = scBlankStr
bDoLoop = True
While bDoLoop
sReadBuffer = scBlankStr
bDoLoop = InternetReadFile(hUrlFile,
If Not CBool(bDoLoop) Then CheckError
lTotalBytesRead = lTotalBytesRead + lNumberOfBytesRead
SetStatus "Reading Url: " & CStr(lTotalBytesRead) & " bytes read"
If CBool(lNumberOfBytesRead) Then
If bWriteToFile Then
Put #iFileNum, , sReadBuffer
Else
sContents = sContents & Left$(sReadBuffer, lNumberOfBytesRead)
End If
Else
bDoLoop = False
bReadInternetFile = True
End If
Wend
InternetCloseHandle (hUrlFile)
If bWriteToFile Then Close
ReadUrl = True
Else
CheckError
End If
SetStatus "Ready"
Screen.MousePointer = vbDefault
Exit Function
errReadUrl:
sLastError = Error$(Err)
Screen.MousePointer = vbDefault
Exit Function
End Function
ASKER
ill try the internet_flag_pragma_nocac he and internet_flag_resynchroniz e flags, but what are the values for these constants?
ASKER
what are the values of all the http constants actually?
good question. microsoft provides no documentation i can find showing the declarations for these constants. damn ms! i will try to look on the web for some project examples that use the wininet api to see if they have the constants declared in them. the info has to be out there somewhere.
Private Type INTERNET_VERSION_INFO
dwMajorVersion As Long
dwMinorVersion As Long
End Type
Private Type HTTP_VERSION_INFO
dwMajorVersion As Long
dwMinorVersion As Long
End Type
Private Const INTERNET_INVALID_PORT_NUMB ER = 0 ' use the protocol-specific default
Private Const INTERNET_DEFAULT_FTP_PORT = 21 ' default for FTP servers
Private Const INTERNET_DEFAULT_GOPHER_PO RT = 70 ' " " gopher "
Private Const INTERNET_DEFAULT_HTTP_PORT = 80 ' " " HTTP "
Private Const INTERNET_DEFAULT_HTTPS_POR T = 443 ' " " HTTPS "
Private Const INTERNET_DEFAULT_SOCKS_POR T = 1080 ' default for SOCKS firewall servers.
' maximum field lengths (arbitrary)
Private Const INTERNET_MAX_HOST_NAME_LEN GTH = 256
Private Const INTERNET_MAX_USER_NAME_LEN GTH = 128
Private Const INTERNET_MAX_PASSWORD_LENG TH = 128
Private Const INTERNET_MAX_PORT_NUMBER_L ENGTH = 5 ' INTERNET_PORT is unsigned short
Private Const INTERNET_MAX_PORT_NUMBER_V ALUE = 65535 ' maximum unsigned short value
Private Const INTERNET_MAX_PATH_LENGTH = 2048
Private Const INTERNET_MAX_SCHEME_LENGTH = 32 ' longest protocol name length
'Private Const INTERNET_MAX_URL_LENGTH (INTERNET_MAX_SCHEME_LENGT H \
' + sizeof("://") \
' + INTERNET_MAX_PATH_LENGTH)
' values returned by InternetQueryOption() with INTERNET_OPTION_KEEP_CONNE CTION:
'Private Const INTERNET_KEEP_ALIVE_UNKNOW N ((DWORD)-1)
Private Const INTERNET_KEEP_ALIVE_ENABLE D = 1
Private Const INTERNET_KEEP_ALIVE_DISABL ED = 0
' flags returned by InternetQueryOption() with INTERNET_OPTION_REQUEST_FL AGS
Private Const INTERNET_REQFLAG_FROM_CACH E = &H1 ' response came from cache
Private Const INTERNET_REQFLAG_ASYNC = &H2 ' request was made asynchronously
Private Const INTERNET_REQFLAG_VIA_PROXY = &H4 ' request was made via a proxy
Private Const INTERNET_REQFLAG_NO_HEADER S = &H8 ' orginal response contained no headers
Private Const INTERNET_REQFLAG_PASSIVE = &H10 ' FTP: passive-mode connection
Private Const INTERNET_REQFLAG_CACHE_WRI TE_DISABLE D = &H40 ' HTTPS: this request not cacheable
' flags common to open functions (not InternetOpen()):
Private Const INTERNET_FLAG_RELOAD = &H80000000 ' retrieve the original item
' flags for InternetOpenUrl():
Private Const INTERNET_FLAG_RAW_DATA = &H40000000 ' FTP/gopher find: receive the item as raw (structured) data
Private Const INTERNET_FLAG_EXISTING_CON NECT = &H20000000 ' FTP: use existing InternetConnect handle for server if possible
' flags for InternetOpen():
Private Const INTERNET_FLAG_ASYNC = &H10000000 ' this request is asynchronous (where supported)
' protocol-specific flags:
Private Const INTERNET_FLAG_PASSIVE = &H8000000 ' used for FTP connections
' additional cache flags
Private Const INTERNET_FLAG_NO_CACHE_WRI TE = &H4000000 ' don't write this item to the cache
Private Const INTERNET_FLAG_DONT_CACHE = INTERNET_FLAG_NO_CACHE_WRI TE
Private Const INTERNET_FLAG_MAKE_PERSIST ENT = &H2000000 ' make this item persistent in cache
Private Const INTERNET_FLAG_FROM_CACHE = &H1000000 ' use offline semantics
Private Const INTERNET_FLAG_OFFLINE = INTERNET_FLAG_FROM_CACHE
' additional flags
Private Const INTERNET_FLAG_SECURE = &H800000 ' use PCT/SSL if applicable (HTTP)
Private Const INTERNET_FLAG_KEEP_CONNECT ION = &H400000 ' use keep-alive semantics
Private Const INTERNET_FLAG_NO_AUTO_REDI RECT = &H200000 ' don't handle redirections automatically
Private Const INTERNET_FLAG_READ_PREFETC H = &H100000 ' do background read prefetch
Private Const INTERNET_FLAG_NO_COOKIES = &H80000 ' no automatic cookie handling
Private Const INTERNET_FLAG_NO_AUTH = &H40000 ' no automatic authentication handling
Private Const INTERNET_FLAG_CACHE_IF_NET _FAIL = &H10000 ' return cache file if net request fails
' Security Ignore Flags, Allow HttpOpenRequest to overide
' Secure Channel (SSL/PCT) failures of the following types.
Private Const INTERNET_FLAG_IGNORE_REDIR ECT_TO_HTT P = &H8000 ' ex: https:' to http://
Private Const INTERNET_FLAG_IGNORE_REDIR ECT_TO_HTT PS = &H4000 ' ex: http:' to https://
Private Const INTERNET_FLAG_IGNORE_CERT_ DATE_INVAL ID = &H2000 ' expired X509 Cert.
Private Const INTERNET_FLAG_IGNORE_CERT_ CN_INVALID = &H1000 ' bad common name in X509 Cert.
' more caching flags
Private Const INTERNET_FLAG_RESYNCHRONIZ E = &H800 ' asking wininet to update an item if it is newer
Private Const INTERNET_FLAG_HYPERLINK = &H400 ' asking wininet to do hyperlinking semantic which works right for scripts
Private Const INTERNET_FLAG_NO_UI = &H200 ' no cookie popup
Private Const INTERNET_FLAG_PRAGMA_NOCAC HE = &H100 ' asking wininet to add "pragma: no-cache"
Private Const INTERNET_FLAG_CACHE_ASYNC = &H80 ' ok to perform lazy cache-write
Private Const INTERNET_FLAG_FORMS_SUBMIT = &H40 ' this is a forms submit
Private Const INTERNET_FLAG_NEED_FILE = &H10 ' need a file for this request
Private Const INTERNET_FLAG_MUST_CACHE_R EQUEST = INTERNET_FLAG_NEED_FILE
' manifests
Private Const FTP_TRANSFER_TYPE_UNKNOWN = &H0
Private Const FTP_TRANSFER_TYPE_ASCII = &H1
Private Const FTP_TRANSFER_TYPE_BINARY = &H2
' flags for FTP
Private Const INTERNET_FLAG_TRANSFER_ASC II = FTP_TRANSFER_TYPE_ASCII ' = &H00000001
Private Const INTERNET_FLAG_TRANSFER_BIN ARY = FTP_TRANSFER_TYPE_BINARY ' = &H00000002
' common per-API flags (new APIs)
Private Const WININET_API_FLAG_ASYNC = &H1 ' force async operation
Private Const WININET_API_FLAG_SYNC = &H4 ' force sync operation
Private Const WININET_API_FLAG_USE_CONTE XT = &H8 ' use value supplied in dwContext (even if 0)
' INTERNET_NO_CALLBACK - if this value is presented as the dwContext parameter
' then no call-backs will be made for that API
Private Const INTERNET_NO_CALLBACK = 0
' INTERNET_SCHEME - enumerated URL scheme type
Public Enum INTERNET_SCHEME
INTERNET_SCHEME_PARTIAL = -2
INTERNET_SCHEME_UNKNOWN = -1
INTERNET_SCHEME_DEFAULT = 0
INTERNET_SCHEME_FTP = 1
INTERNET_SCHEME_GOPHER = 2
INTERNET_SCHEME_HTTP = 3
INTERNET_SCHEME_HTTPS = 4
INTERNET_SCHEME_FILE = 5
INTERNET_SCHEME_NEWS = 6
INTERNET_SCHEME_MAILTO = 7
INTERNET_SCHEME_SOCKS = 8
INTERNET_SCHEME_FIRST = INTERNET_SCHEME_FTP
INTERNET_SCHEME_LAST = INTERNET_SCHEME_SOCKS
End Enum
' flags for InternetCanonicalizeUrl() and InternetCombineUrl()
Private Const ICU_NO_ENCODE = &H20000000 ' Don't convert unsafe characters to escape sequence
Private Const ICU_DECODE = &H10000000 ' Convert %XX escape sequences to characters
Private Const ICU_NO_META = &H8000000 ' Don't convert .. etc. meta path sequences
Private Const ICU_ENCODE_SPACES_ONLY = &H4000000 ' Encode spaces only
Private Const ICU_BROWSER_MODE = &H2000000 ' Special encode/decode rules for browser
Private Declare Function InternetCanonicalizeUrl Lib "wininet.dll" Alias "InternetCanonicalizeUrlA" (ByVal lpszUrl As String, ByVal lpszBuffer As String, lpdwBufferLength As Long, ByVal dwFlags As Long) As Long
Private Declare Function InternetCombineUrl Lib "wininet.dll" Alias "InternetCombineUrlA" (ByVal lpszBaseUrl As String, ByVal lpszRelativeUrl As String, ByVal lpszBuffer As String, lpdwBufferLength As Long, ByVal dwFlags As Long) As Long
' access types for InternetOpen()
Private Const INTERNET_OPEN_TYPE_PRECONF IG = 0 ' use registry configuration
Private Const INTERNET_OPEN_TYPE_DIRECT = 1 ' direct to net
Private Const INTERNET_OPEN_TYPE_PROXY = 3 ' via named proxy
Private Const INTERNET_OPEN_TYPE_PRECONF IG_WITH_NO _AUTOPROXY = 4 ' prevent using java/script/INS
' old names for access types
Private Const PRE_CONFIG_INTERNET_ACCESS = INTERNET_OPEN_TYPE_PRECONF IG
Private Const LOCAL_INTERNET_ACCESS = INTERNET_OPEN_TYPE_DIRECT
Private Const CERN_PROXY_INTERNET_ACCESS = INTERNET_OPEN_TYPE_PROXY
' opens and initializes an internet connection
Private Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" (ByVal lpszAgent As String, ByVal dwAccessType As Long, ByVal lpszProxyName As String, ByVal lpszProxyBypass As String, ByVal dwFlags As Long) As Long
' closes a internet connection or URL handle
Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Integer
' opens a URL
Private Declare Function InternetOpenUrl Lib "wininet.dll" Alias "InternetOpenUrlA" (ByVal hInternetSession As Long, ByVal lpszUrl As String, ByVal lpszHeaders As String, ByVal dwHeadersLength As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Long
' reads data from a URL
Private Declare Function InternetReadFile Lib "wininet.dll" (ByVal hFile As Long, ByVal lpBuffer As String, ByVal dwNumberOfBytesToRead As Long, lNumberOfBytesRead As Long) As Integer
' INTERNET_ASYNC_RESULT - this structure is returned to the application via
' the callback with INTERNET_STATUS_REQUEST_CO MPLETE. It is not sufficient to
' just return the result of the async operation. If the API failed then the
' app cannot call GetLastError() because the thread context will be incorrect.
' Both the value returned by the async API and any resultant error code are
' made available. The app need not check dwError if dwResult indicates that
' the API succeeded (in this case dwError will be ERROR_SUCCESS)
Private Type INTERNET_ASYNC_RESULT
' dwResult - the HINTERNET, DWORD or BOOL return code from an async API
dwResult As Long
' dwError - the error code if the API failed
dwError As Long
End Type
Private Const INTERNET_FLAG_EXISITING_CO NNECT = &H20000000
Private Const scTagDelimiter = """>?#" ' default delimiter when scanning HTML
Private Const scBlankStr = "" ' blank string constant
Private hInternetSession As Long ' internet session handle
Private bInitialized As Boolean ' object initialization flag
Private hUrlFile As Long ' utl handle
Private sContents As String ' html page contents
Private sLastError As String ' last dll error buffer
Private sStatus As String ' object status buffer
Private objWindow As Object ' status message window
Private sUserAgent As String ' user agent in HTTP protocol
dwMajorVersion As Long
dwMinorVersion As Long
End Type
Private Type HTTP_VERSION_INFO
dwMajorVersion As Long
dwMinorVersion As Long
End Type
Private Const INTERNET_INVALID_PORT_NUMB
Private Const INTERNET_DEFAULT_FTP_PORT = 21 ' default for FTP servers
Private Const INTERNET_DEFAULT_GOPHER_PO
Private Const INTERNET_DEFAULT_HTTP_PORT
Private Const INTERNET_DEFAULT_HTTPS_POR
Private Const INTERNET_DEFAULT_SOCKS_POR
' maximum field lengths (arbitrary)
Private Const INTERNET_MAX_HOST_NAME_LEN
Private Const INTERNET_MAX_USER_NAME_LEN
Private Const INTERNET_MAX_PASSWORD_LENG
Private Const INTERNET_MAX_PORT_NUMBER_L
Private Const INTERNET_MAX_PORT_NUMBER_V
Private Const INTERNET_MAX_PATH_LENGTH = 2048
Private Const INTERNET_MAX_SCHEME_LENGTH
'Private Const INTERNET_MAX_URL_LENGTH (INTERNET_MAX_SCHEME_LENGT
' + sizeof("://") \
' + INTERNET_MAX_PATH_LENGTH)
' values returned by InternetQueryOption() with INTERNET_OPTION_KEEP_CONNE
'Private Const INTERNET_KEEP_ALIVE_UNKNOW
Private Const INTERNET_KEEP_ALIVE_ENABLE
Private Const INTERNET_KEEP_ALIVE_DISABL
' flags returned by InternetQueryOption() with INTERNET_OPTION_REQUEST_FL
Private Const INTERNET_REQFLAG_FROM_CACH
Private Const INTERNET_REQFLAG_ASYNC = &H2 ' request was made asynchronously
Private Const INTERNET_REQFLAG_VIA_PROXY
Private Const INTERNET_REQFLAG_NO_HEADER
Private Const INTERNET_REQFLAG_PASSIVE = &H10 ' FTP: passive-mode connection
Private Const INTERNET_REQFLAG_CACHE_WRI
' flags common to open functions (not InternetOpen()):
Private Const INTERNET_FLAG_RELOAD = &H80000000 ' retrieve the original item
' flags for InternetOpenUrl():
Private Const INTERNET_FLAG_RAW_DATA = &H40000000 ' FTP/gopher find: receive the item as raw (structured) data
Private Const INTERNET_FLAG_EXISTING_CON
' flags for InternetOpen():
Private Const INTERNET_FLAG_ASYNC = &H10000000 ' this request is asynchronous (where supported)
' protocol-specific flags:
Private Const INTERNET_FLAG_PASSIVE = &H8000000 ' used for FTP connections
' additional cache flags
Private Const INTERNET_FLAG_NO_CACHE_WRI
Private Const INTERNET_FLAG_DONT_CACHE = INTERNET_FLAG_NO_CACHE_WRI
Private Const INTERNET_FLAG_MAKE_PERSIST
Private Const INTERNET_FLAG_FROM_CACHE = &H1000000 ' use offline semantics
Private Const INTERNET_FLAG_OFFLINE = INTERNET_FLAG_FROM_CACHE
' additional flags
Private Const INTERNET_FLAG_SECURE = &H800000 ' use PCT/SSL if applicable (HTTP)
Private Const INTERNET_FLAG_KEEP_CONNECT
Private Const INTERNET_FLAG_NO_AUTO_REDI
Private Const INTERNET_FLAG_READ_PREFETC
Private Const INTERNET_FLAG_NO_COOKIES = &H80000 ' no automatic cookie handling
Private Const INTERNET_FLAG_NO_AUTH = &H40000 ' no automatic authentication handling
Private Const INTERNET_FLAG_CACHE_IF_NET
' Security Ignore Flags, Allow HttpOpenRequest to overide
' Secure Channel (SSL/PCT) failures of the following types.
Private Const INTERNET_FLAG_IGNORE_REDIR
Private Const INTERNET_FLAG_IGNORE_REDIR
Private Const INTERNET_FLAG_IGNORE_CERT_
Private Const INTERNET_FLAG_IGNORE_CERT_
' more caching flags
Private Const INTERNET_FLAG_RESYNCHRONIZ
Private Const INTERNET_FLAG_HYPERLINK = &H400 ' asking wininet to do hyperlinking semantic which works right for scripts
Private Const INTERNET_FLAG_NO_UI = &H200 ' no cookie popup
Private Const INTERNET_FLAG_PRAGMA_NOCAC
Private Const INTERNET_FLAG_CACHE_ASYNC = &H80 ' ok to perform lazy cache-write
Private Const INTERNET_FLAG_FORMS_SUBMIT
Private Const INTERNET_FLAG_NEED_FILE = &H10 ' need a file for this request
Private Const INTERNET_FLAG_MUST_CACHE_R
' manifests
Private Const FTP_TRANSFER_TYPE_UNKNOWN = &H0
Private Const FTP_TRANSFER_TYPE_ASCII = &H1
Private Const FTP_TRANSFER_TYPE_BINARY = &H2
' flags for FTP
Private Const INTERNET_FLAG_TRANSFER_ASC
Private Const INTERNET_FLAG_TRANSFER_BIN
' common per-API flags (new APIs)
Private Const WININET_API_FLAG_ASYNC = &H1 ' force async operation
Private Const WININET_API_FLAG_SYNC = &H4 ' force sync operation
Private Const WININET_API_FLAG_USE_CONTE
' INTERNET_NO_CALLBACK - if this value is presented as the dwContext parameter
' then no call-backs will be made for that API
Private Const INTERNET_NO_CALLBACK = 0
' INTERNET_SCHEME - enumerated URL scheme type
Public Enum INTERNET_SCHEME
INTERNET_SCHEME_PARTIAL = -2
INTERNET_SCHEME_UNKNOWN = -1
INTERNET_SCHEME_DEFAULT = 0
INTERNET_SCHEME_FTP = 1
INTERNET_SCHEME_GOPHER = 2
INTERNET_SCHEME_HTTP = 3
INTERNET_SCHEME_HTTPS = 4
INTERNET_SCHEME_FILE = 5
INTERNET_SCHEME_NEWS = 6
INTERNET_SCHEME_MAILTO = 7
INTERNET_SCHEME_SOCKS = 8
INTERNET_SCHEME_FIRST = INTERNET_SCHEME_FTP
INTERNET_SCHEME_LAST = INTERNET_SCHEME_SOCKS
End Enum
' flags for InternetCanonicalizeUrl() and InternetCombineUrl()
Private Const ICU_NO_ENCODE = &H20000000 ' Don't convert unsafe characters to escape sequence
Private Const ICU_DECODE = &H10000000 ' Convert %XX escape sequences to characters
Private Const ICU_NO_META = &H8000000 ' Don't convert .. etc. meta path sequences
Private Const ICU_ENCODE_SPACES_ONLY = &H4000000 ' Encode spaces only
Private Const ICU_BROWSER_MODE = &H2000000 ' Special encode/decode rules for browser
Private Declare Function InternetCanonicalizeUrl Lib "wininet.dll" Alias "InternetCanonicalizeUrlA"
Private Declare Function InternetCombineUrl Lib "wininet.dll" Alias "InternetCombineUrlA" (ByVal lpszBaseUrl As String, ByVal lpszRelativeUrl As String, ByVal lpszBuffer As String, lpdwBufferLength As Long, ByVal dwFlags As Long) As Long
' access types for InternetOpen()
Private Const INTERNET_OPEN_TYPE_PRECONF
Private Const INTERNET_OPEN_TYPE_DIRECT = 1 ' direct to net
Private Const INTERNET_OPEN_TYPE_PROXY = 3 ' via named proxy
Private Const INTERNET_OPEN_TYPE_PRECONF
' old names for access types
Private Const PRE_CONFIG_INTERNET_ACCESS
Private Const LOCAL_INTERNET_ACCESS = INTERNET_OPEN_TYPE_DIRECT
Private Const CERN_PROXY_INTERNET_ACCESS
' opens and initializes an internet connection
Private Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" (ByVal lpszAgent As String, ByVal dwAccessType As Long, ByVal lpszProxyName As String, ByVal lpszProxyBypass As String, ByVal dwFlags As Long) As Long
' closes a internet connection or URL handle
Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Integer
' opens a URL
Private Declare Function InternetOpenUrl Lib "wininet.dll" Alias "InternetOpenUrlA" (ByVal hInternetSession As Long, ByVal lpszUrl As String, ByVal lpszHeaders As String, ByVal dwHeadersLength As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Long
' reads data from a URL
Private Declare Function InternetReadFile Lib "wininet.dll" (ByVal hFile As Long, ByVal lpBuffer As String, ByVal dwNumberOfBytesToRead As Long, lNumberOfBytesRead As Long) As Integer
' INTERNET_ASYNC_RESULT - this structure is returned to the application via
' the callback with INTERNET_STATUS_REQUEST_CO
' just return the result of the async operation. If the API failed then the
' app cannot call GetLastError() because the thread context will be incorrect.
' Both the value returned by the async API and any resultant error code are
' made available. The app need not check dwError if dwResult indicates that
' the API succeeded (in this case dwError will be ERROR_SUCCESS)
Private Type INTERNET_ASYNC_RESULT
' dwResult - the HINTERNET, DWORD or BOOL return code from an async API
dwResult As Long
' dwError - the error code if the API failed
dwError As Long
End Type
Private Const INTERNET_FLAG_EXISITING_CO
Private Const scTagDelimiter = """>?#" ' default delimiter when scanning HTML
Private Const scBlankStr = "" ' blank string constant
Private hInternetSession As Long ' internet session handle
Private bInitialized As Boolean ' object initialization flag
Private hUrlFile As Long ' utl handle
Private sContents As String ' html page contents
Private sLastError As String ' last dll error buffer
Private sStatus As String ' object status buffer
Private objWindow As Object ' status message window
Private sUserAgent As String ' user agent in HTTP protocol
ASKER
Private Const INTERNET_FLAG_RESYNCHRONIZ E = &H800, this does the trick thanks.
Also cheers for those other http constants.
Also cheers for those other http constants.
Hope this helps you
regards
danny