OVERLAPPED Structure
The OVERLAPPED structure is used with asynchronous I/O operations on devices that support overlapped I/O. It provides the necessary information to track the progress of an asynchronous operation.
Members
typedef struct _OVERLAPPED { ULONG_PTR Internal; ULONG_PTR InternalHigh; union { struct { DWORD Offset; DWORD OffsetHigh; }; PVOID Pointer; }; HANDLE hEvent; } OVERLAPPED, *POVERLAPPED;
Member | Type | Description |
---|---|---|
Internal |
ULONG_PTR |
This member is reserved and should not be used. |
InternalHigh |
ULONG_PTR |
This member is reserved and should not be used. |
Offset |
DWORD |
The byte offset within the file at which to start the transfer. This member is used for file I/O. |
OffsetHigh |
DWORD |
A 32-bit high-order value for the file offset. This member is used in conjunction with Offset to specify a 64-bit file offset for file I/O.
|
Pointer |
PVOID |
This member can be used for user-defined data. It is typically set to NULL when not in use for file I/O.
|
hEvent |
HANDLE |
A handle to an event object that is signaled when the I/O operation has completed. If this member is NULL , the application can poll the I/O status, or the system can use the event associated with the file handle.
|
Remarks
When you use the OVERLAPPED
structure to initiate an asynchronous operation, the system uses the structure to keep track of the operation's status. The Offset
and OffsetHigh
members specify the starting position for the operation within the file. For operations that do not use file offsets (e.g., network operations), the union allows you to use the Pointer
member to associate user-defined data with the operation.
The hEvent
member is crucial for synchronizing asynchronous operations. If you create an event object and pass its handle in hEvent
, the system will signal this event when the operation completes. You can then wait on this event using functions like WaitForSingleObject
.