Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

BUG: Bytes Read Is Not Set on Asynchronous InternetReadFile


View products that this article applies to.

This article was previously published under Q255580

↑ Back to the top


Symptoms

If you call FtpOpenFile and then InternetReadFile asynchronously, lpdwNumberOfBytesRead is not updated when the operation concludes.

Also, the INTERNET_STATUS_REQUEST_COMPLETE notification for InternetReadFile, dwResult, and dwError in (LPINTERNET_ASYNC_RESULT) lpvStatusInfo contains incorrect values.

The problem only occurs in Internet Explorer 5, not Internet Explorer 4.x.

↑ Back to the top


Resolution

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.
				
  1. 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
  2. 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.

↑ Back to the top


Status

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

↑ Back to the top


Keywords: KB255580, kbpending, kbbug

↑ Back to the top

Article Info
Article ID : 255580
Revision : 3
Created on : 10/2/2003
Published on : 10/2/2003
Exists online : False
Views : 359