WriteFile lpNumberOfBytesWritten less than nNumberOfBytesToWrite
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.
精彩评论