win32 GetOverlappedResult

参考网页:

https://msdn.microsoft.com/en-us/library/windows/desktop/ms683209(v=vs.85).aspx

获取在特定的文件上的异步操作的结果。
如果要制定超时时间或者等待一个报警的线程,可以使用函数GetOverlappedResultEx

BOOL WINAPI GetOverlappedResult(
  _In_  HANDLE       hFile,
  _In_  LPOVERLAPPED lpOverlapped,
  _Out_ LPDWORD      lpNumberOfBytesTransferred,
  _In_  BOOL         bWait
);

参数:

hFile [in]

A handle to the file, named pipe, or communications device. This is the same handle that was specified when the overlapped operation was started by a call to the ReadFile, WriteFile, ConnectNamedPipe, TransactNamedPipe, DeviceIoControl, or WaitCommEvent function.

lpOverlapped [in]

A pointer to an OVERLAPPED structure that was specified when the overlapped operation was started.
lpNumberOfBytesTransferred [out]
A pointer to a variable that receives the number of bytes that were actually transferred by a read or write operation. For a TransactNamedPipe operation, this is the number of bytes that were read from the pipe. For a DeviceIoControl operation, this is the number of bytes of output data returned by the device driver. For a ConnectNamedPipe or WaitCommEvent operation, this value is undefined.

bWait [in]

如果这个值是TRUE ,会一直等待异步操作完成
如果这个值为FALSE,程序只返回当前的状态,并立即返回
If this parameter is TRUE, and the Internal member of the lpOverlapped structure is STATUS_PENDING, the function does not return until the operation has been completed. If this parameter is FALSE and the operation is still pending, the function returns FALSE and the GetLastError function returns ERROR_IO_INCOMPLETE.

返回值

If the function succeeds, the return value is nonzero.TRUE
If the function fails, the return value is zero.FALSE
To get extended error information, call GetLastError.

猜你喜欢

转载自blog.csdn.net/wowocpp/article/details/80525057