Take the 2-minute tour ×

Supposed I have something like this

readFile(.....&ol) //with overlapped






I noticed that both readfiles read from the beginning of the file...why? In a normal readfile without overlapped/asynchronization the second readfile would start off where the first ended..

share|improve this question
To increase your chances of getting help: 1. Post a complete compilable code fragment that demonstrates the behavior. 2. Tag the question appropriately. –  NPE Apr 11 '11 at 11:39
msdn.microsoft.com/en-us/library/aa365467(VS.85).aspx I suggest MSDN is the reference for questions regarding Microsoft API functions and parameters. –  hplbsh Apr 11 '11 at 14:55
add comment

1 Answer

up vote 1 down vote accepted

When using overlapped I/O on a file, you pass a pointer to an OVERLAPPED object, in this case ol.

The OVERLAPPED struct has two variables, Offset and OffsetHigh. These two variables are combined into a 64-bit integer, with Offset being the lower-order DWORD and OffsetHigh being the high-order DWORD, and used as the offset to perform the I/O operation at.

So, for example, if you wanted to start a ReadFile at the 8th byte of the file, you would set the Offset variable to 8 and the OffsetHigh variable to 0 before passing the OVERLAPPED to ReadFile.

share|improve this answer
As an extra tip: this is only required for reading files. When using asynchronous I/O with sockets, setting this member is not necessary. –  André Caron Apr 11 '11 at 13:02
add comment

Your Answer


