There are two examples that use ioCompletionPorts in the platform SDK. One uses a single thread and the second, two threads. They both simply copy a file.
After compiling and trying them both, the version with two threads works fine but the single thread version seems not to. It creates a copied file the same size but without all the contents. On closer investigation it would seem that the Key "returned" from
Code:
while (PendingIO) {
Success = GetQueuedCompletionStatus(IoPort,
&NumberBytes,
&Key,
&CompletedOverlapped,
INFINITE);
is never set to WriteKey and therefore the program just completes 20 reads and 20 writes. It then extends the output file the the same length as the input file, effectively filling the file with hex 00.
(You'll only see this if the input file is bigger than 64KB*20).
Does this example work for anyone else or is it just wrong? If so, can anyone correct it?
......\Microsoft SDK\Samples\winbase\IO\UnBufCpy\UnBufCp1.c
Tim