To work around this problem, use the following procedure, which is based on the fact that InternetReadFile yields these values in LPINTERNET_ASYNC_RESULT structure:
SUCCESS: dwResult = 1; dwError = bytes read (IE5) or 0 (IE4)
FAILURE: dwResult = 0; dwError = error code.
- Check the Internet Explorer version programmatically as shown in the following Knowledge Base article:
244857�
HOWTO: Interpret the Results of InternetQueryOption with the INTERNET_VERSION_INFO Structure
- If the version number is Internet Explorer 5, modify the callback function as follows:
void CALLBACK InternetCallback(HINTERNET hInternet,
DWORD dwContext, DWORD dwInternetStatus, void* lpStatusInfo,
DWORD dwStatusInfoLength)
{
strProgress *pProgress;
switch(dwInternetStatus)
{
...
case INTERNET_STATUS_REQUEST_COMPLETE:
INTERNET_ASYNC_RESULT* pResult;
pResult = (INTERNET_ASYNC_RESULT*)lpStatusInfo;
pProgress = (strProgress*)dwContext;
pProgress->dwError = pResult->dwError;
pProgress->dwResult = pResult->dwResult;
pProgress->bComplete = true;
if (pResult->dwResult == 1 && pProgress->type == TYPE_READFILE)
{
//pResult->dwError actually stores the bytes read for InternetReadFile in IE5
pProgress->dwResult = pResult->dwError;
pProgress->dwError = ERROR_SUCCESS;
}
break;
}
...
}
In the main() function, pProgress->dwError will then contain the number of bytes read if pProgress->dwError is ERROR_SUCCESS.