Microsoft KB Archive/255580

= BUG: Bytes Read Is Not Set on Asynchronous InternetReadFile =

Article ID: 255580

Article Last Modified on 10/2/2003

-

APPLIES TO


 * Microsoft Internet Explorer 5.0
 * Microsoft Internet Explorer 5.01
 * Microsoft Internet Explorer 5.5

-



This article was previously published under Q255580



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.



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



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

Keywords: kbbug kbpending KB255580

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.