Hello
I found the following code that should show how to use InternetReadFileEx
do
{
INTERNET_BUFFERS InetBuff;
FillMemory(&InetBuff, sizeof(InetBuff), 0);
InetBuff.dwStructSize = sizeof(InetBuff);
InetBuff.lpvBuffer = lpReadBuff;
InetBuff.dwBufferLength = sizeof(lpReadBuff) - 1;
if (bVerbose)
{
cout << "Calling InternetReadFileEx" << endl;
cout.flush();
}
if (!InternetReadFileEx(hRequest,
&InetBuff,
0, 2))
{
if (GetLastError() == ERROR_IO_PENDING)
{
if (bVerbose)
{
cout << "Waiting for InternetReadFileEx to complete" <<
endl;
cout.flush();
}
WaitForSingleObject(hRequestCompleteEvent, INFINITE);
}
else
{
cout << "InternetReadFileEx failed, error " <<
GetLastError();
cout.flush();
return;
}
}
lpReadBuff[InetBuff.dwBufferLength] = 0;
cout << lpReadBuff;
cout.flush();
if (InetBuff.dwBufferLength == 0)
bAllDone = TRUE;
} while (bAllDone == FALSE);
Thanks
Brian [MSFT]
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| Date: Wed, 13 Oct 2004 12:10:03 +0200
| From: pokko <***@microsoft.com>
| User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913)
| X-Accept-Language: en-us, en
| MIME-Version: 1.0
| Subject: Detect end of file when using InternetReadFileEx
| Content-Type: text/plain; charset=ISO-8859-1; format=flowed
| Content-Transfer-Encoding: 7bit
| Message-ID: <#***@TK2MSFTNGP11.phx.gbl>
| Newsgroups: microsoft.public.inetsdk.programming.wininet
| NNTP-Posting-Host: 81-202-160-110.user.ono.com 81.202.160.110
| Lines: 1
| Path:
cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11
.phx.gbl
| Xref: cpmsftngxa10.phx.gbl
microsoft.public.inetsdk.programming.wininet:11773
| X-Tomcat-NG: microsoft.public.inetsdk.programming.wininet
|
| How do I know when I've reached the end of data
| when I'm grabbing a web page using InternetReadFileEx?
|
| When I get to the end of the input data my program
| just goes into a loop with InternetReadFileEx
| returning zero bytes read. How do I spot the EOF
| condition?
|
|
|