Re: WriteFile()
- From: "Hector Santos" <nospamhere@xxxxxxxxxxxxxx>
- Date: Sun, 18 Jun 2006 04:05:53 GMT
Chris said it was possible.
Unless he knows something unbeknownst to me, I don't think so. I can't
think of any normal condition where this is possible.
In sync mode, the WriteFile() operation must complete, otherwise there is a
underlining problem. Like possibly out of disk space, in which case you
can get less than the requested write amount. WriteFile() returns false the
extended error is ERROR_DISK_FULL.
In async mode, it is possible to get less than the requested write. That's
the whole purpose of async.
So you are correct, the lpNumberOfBytesWritten is redundant in SYNC mode,
and this is highlighted by the MSDN documentation where it says it can be
NULL in sync mode (starting with Windows 2000).
Just think about it. In sync mode, what physical barrier could there be
that can produce partial write?
I can only see a disk error, or maybe the handle becoming invalid or some
other conflict while the write is happening, but these should also produce a
FALSE result. You should never get TRUE for errors otherwise the world
will blow up. <g>
--
Hector Santos, Santronics Software, Inc.
http://www.santronics.com
"Frank A. Uepping" <trash@xxxxxxxxxxxxxxx> wrote in message
news:d36ppn$84f$05$2@xxxxxxxxxxxxxxxxxxxx
Hello,
Can we always assume that when WriteFile() (in synchronous operation
mode) returns successfully it has written the requested number of bytes,
i.e. nNumberOfBytesToWrite == *lpNumberOfBytesWritten?
Or is it legal for WriteFile() to return successfully without having
written all requested bytes, i.e. nNumberOfBytesToWrite >
*lpNumberOfBytesWritten?
(I assume the latter, otherwise I see no sense for having
lpNumberOfBytesWritten.)
Thanks
FAU
.
- Follow-Ups:
- Re: WriteFile()
- From: Frank A. Uepping
- Re: WriteFile()
- Prev by Date: Re: more CommEvents than expected
- Next by Date: Re: WriteFile()
- Previous by thread: Re: WriteFile()
- Next by thread: Re: WriteFile()
- Index(es):
Relevant Pages
|