ReadFile() at EOF Changed in Windows NT 3.5
  
PSS ID Number: Q119220
Article last modified on 01-05-1995
 
3.50
 
WINDOWS NT
 

----------------------------------------------------------------------
The information in this article applies to:
 
 - Microsoft Win32 Software Development Kit (SDK) for Windows NT
   version 3.5
----------------------------------------------------------------------
 
The documentation for ReadFile() states that:
 
   If the function succeeds, the return value is TRUE. If the return value
   is TRUE and the number of bytes read is zero, the file pointer was
   beyond the current end of file at the time of the read operation.
 
   If the function fails, the return value is FALSE. To get extended error
   information, call GetLastError().
 
Under Windows NT 3.1, when you read at the end of the file (EOF),
ReadFile() returns TRUE and reports that 0 (zero) bytes were read. However,
if you are using asynchronous I/O and EOF is reached, GetOverlappedResult()
will hang because there is no outstanding I/O. ReadFileEx() properly
handles EOF by failing and setting the error code to ERROR_HANDLE_EOF.
 
Under Windows NT 3.5, ReadFile() returns FALSE and GetLastError() returns
error 38 (ERROR_HANDLE_EOF) for asynchronous I/O. This change in behavior
was made to avoid the problem described above. The behavior for synchronous
I/O has not changed under Windows NT 3.5.
 
Additional reference words: 3.50
KBCategory: kbprg
KBSubcategory: BseFileio
 
=============================================================================
 
Copyright Microsoft Corporation 1995.
