Re: InternetReadFileEx



Thanks, but it fails, returning error #6 to the debug window. What is the
interpretation of that error?

"Mike D Sutton" wrote:

Anybody here knows how to successfully use InternetReadFileEX. In
particular
the settings for the INTERNET_BUFFERS structure properties: This structure
has an embedded INTERNET_BUFFERS property. What are the possible settings
for
this?

Try something like this:

'***
Private Declare Function InternetReadFileEx Lib "WinINet.dll" Alias
"InternetReadFileExA" ( _
ByVal hFile As Long, ByRef lpBuffersOut As INTERNET_BUFFERS, _
ByVal dwFlags As Long, ByVal dwContext As Long) As Long

Private Type INTERNET_BUFFERS
dwStructSize As Long
Next As Long
lpcszHeader As Long ' LPCTSTR
dwHeadersLength As Long
dwHeadersTotal As Long
lpvBuffer As Long ' LPVIOD
dwBufferLength As Long
dwBufferTotal As Long
dwOffsetLow As Long
dwOffsetHigh As Long
End Type

Const WININET_API_FLAG_ASYNC As Long = &H1 ' Force async operation
Const IRF_ASYNC As Long = WININET_API_FLAG_ASYNC

....

Const BufLen As Long = 1024

Dim hNetFile As Long
Dim OutBuffer As INTERNET_BUFFERS
Dim Buffer(0 To BufLen - 1) As Byte

' Open file
hNetFile = InternetOpenUrl( ... )
If (hNetFile) Then
' Set up return buffer structure
OutBuffer.dwStructSize = Len(OutBuffer)
OutBuffer.dwBufferLength = BufLen
OutBuffer.lpvBuffer = VarPtr(Buffer(0))

' Attempt to read first chunk from file
If (InternetReadFileEx(hNetFile, OutBuffer, IRF_ASYNC, 0&)) Then
Do While OutBuffer.dwBufferLength > 0
' Do something with this buffer (0 to OutBuffer.dwBufferLength -
1 bytes)
Call InternetReadFileEx(hNetFile, OutBuffer, IRF_ASYNC, 0&)
Loop
Else
Debug.Print "InternetReadFileEx error: " & CStr(Err.LastDllError)
End If
End If

' Close file
Call InternetCloseHandle(hNetFile)
'***

Don't try and use the Unicode version of the function, it seems that it's
not implemented and will simply fail if you try.
Hope this helps,

Mike


- Microsoft Visual Basic MVP -
E-Mail: EDais@xxxxxxxx
WWW: Http://EDais.mvps.org/



.



Relevant Pages

  • Re: InternetReadFileEx
    ... the settings for the INTERNET_BUFFERS structure properties: ... What are the possible settings ... Dim hNetFile As Long ... Dim OutBuffer As INTERNET_BUFFERS ...
    (microsoft.public.vb.winapi)
  • Re: OT--MS Vista
    ... Never fails to make me chuckle;-) ... have an issue with my computer boot up. ... Tweak UI - This PowerToy gives you access to system settings that are ... Version 2.10 requires Windows XP Service Pack 1 or Windows Server ...
    (rec.food.cooking)
  • Re: Outlook "Test Account Settings .... " Slow to Receive emails
    ... Assuming that the slowness is at the ISP, then why does Outlook Express wait ... without failure and Outlook fails / times out? ... I've tried all the GUI settings that I ... > On some computers, some of the time, Receiving fails. ...
    (microsoft.public.outlook)
  • Re: WEEKDAY()
    ... As RD says the second version of that works for you, but fails for me is ... because we have different date settings, yours are American, mine are ... were gospel. ...
    (microsoft.public.excel.newusers)
  • Re: Cant send email from Outlook?
    ... Error messages? ... The user was using Outlook Express and all settings worked fine. ... > Outlook fails. ...
    (microsoft.public.outlook.installation)