开发者

WriteFile lpNumberOfBytesWritten less than nNumberOfBytesToWrite

开发者 https://www.devze.com 2023-02-19 11:29 出处:网络
When calling WriteFile can the returned lpNumberOfBytesWritten ever be less than nNumberOfBytesToWrite in synchronous write mode where an error has not occured (return is TRUE)? Wri开发者_运维问答ting

When calling WriteFile can the returned lpNumberOfBytesWritten ever be less than nNumberOfBytesToWrite in synchronous write mode where an error has not occured (return is TRUE)? Wri开发者_运维问答ting is done to a proper file (not a socket, pipe, or other special handle). lpOverlapped is not used.

It is not entirely clear from the docs.


The documentation states:

The WriteFile function returns when one of the following conditions occur:

  • The number of bytes requested is written.
  • A read operation releases buffer space on the read end of the pipe (if the write was blocked). For more information, see the Pipes section.
  • An asynchronous handle is being used and the write is occurring asynchronously.
  • An error occurs.

Only the first one of these meets your criteria so the answer is that the documentation is clear *lpNumberOfBytesWritten is always equal to nNumberOfBytesToWrite when the function returns when called as you specify.

0

精彩评论

暂无评论...
验证码 换一张
取 消