Here is the prototype...

BOOL InternetReadFile(
HINTERNET hFile,
LPVOID lpBuffer,
DWORD dwNumberOfBytesToRead,
LPDWORD lpdwNumberOfBytesRead
);

Let me explain the problem I am having by showing you a little example:

char *lpBuffer[2000];
DWORD lpdwNumberOfBytesRead = 0;
BOOL bRetval;
HINTERNET hInternet, hFile;

char url[] = "http://www.cnn.com"; // whatever -- not important

hInternet = InternetOpen(" ",
INTERNET_OPEN_TYPE_DIRECT,
NULL, NULL, 0);
if(!hInternet)
MessageBox(hwnd, "Could not open connection", "InternetOpen", MB_OK | MB_ICONERROR);


hFile = InternetOpenUrl(hInternet,
url,
NULL, 0, INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_NEED_FILE |
INTERNET_FLAG_NO_COOKIES
, 0);
if(hFile != NULL)
{
for( ; ; )
{
bRetval = InternetReadFile( hFile, lpBuffer, 2000, &lpdwNumberOfBytesRead);
if(bRetval && lpdwNumberOfBytesRead == 0)
break;
// I would include code here to null terminate lpBuffer
}
}
Now, in this example, which works perfectly, the third parameter of InternetReadFile is set to equal the size of lpBuffer. But when I set the third parameter, or the number of bytes I want read per call to the InternetReadFile function, to less than the size of lpBuffer -- lets say to 1000 -- I get unwanted results. For instance, with the third parameter set to 1000 the first 1000 bytes of data is written to lpBuffer without a problem, but the remaining 1000 bytes of data, which is suppose to be written when InternetReadFile is called for the second time within the for loop, is not being written to lpBuffer at all. The end result: a file that is suppose to be 2000 bytes long but actually only contains 1000 bytes of data. This is the sort of problem I am having. Does anyone know why?

thanks

Echidna