FileIoCompletionRoutine

  VOID FileIoCompletionRoutine(fdwError, cbTransferred, lpo)    
  DWORD fdwError; /* completion code */
  DWORD cbTransferred; /* number of bytes transferred */
  LPOVERLAPPED lpo; /* address of structure with I/O information */

The FileIoCompletionRoutine function is called when an asynchronous I/O function (ReadFileEx or WriteFileEx) completes and the calling thread is in an alertable wait (using the SleepEx, WaitForSingleObjectEx, or WaitForMultipleObjectsEx function with the fAlertable flag set to TRUE).

Parameters

fdwError

Specifies the I/O completion status, and may be one of the following values:

Value Meaning

0 The I/O was successful.
ERROR_HANDLE_EOF The ReadFileEx function tried to read past the end of the file.

cbTransferred

Specifies the number of bytes transferred. This parameter is zero if an error occurred.

lpo

Points to the OVERLAPPED structure specified with the asynchronous I/O function. Win32 does not use the hEvent member of this structure; the calling application may use this member to pass information to the completion routine. Win32 does not use the OVERLAPPED structure once the completion routine is called, so the completion routine is free to deallocate the overlapped structure.

Return Value

This function does not return a value.

Comments

FileIOCompletionRoutine is a placeholder for the application- or library-supplied function name.

Returning from this function allows another pending I/O completion routine to be called. All waiting completion routines are called before the alertable thread's wait is satisfied (with a return code of WAIT_IO_COMPLETION). Win32 may call the waiting completion routines in any order (they may or may not be called in the order the I/O functions completed).

Note that each time Win32 calls a completion routine, it uses some of the application's stack. If the completion routine does additional asynchronous I/O and alertable waits, the stack may grow without shrinking.

See Also

ReadFileEx, SleepEx, WaitForMultipleObjectsEx, WaitForSingleObjectEx, WriteFileEx