The short answer isthat you can't ;). Once you have opened a HANDLE by
specifying FILE_FLAG_OVERLAPPED, you must provide an OVERLAPPED structure pointer to
any HANDLE based API that requires it. If you don't provide the pointer, the
results are undefined. This is spelled out in the docs and I don't see this
mistake being made all that often.
But what about the hEvent field in OVERLAPPED in the structure? Do you
always have to allocate an event HANDLE? One problem with always have to allocate
the event HANDLE is that it is yet another point of failure, yet another code
path that you have to test. Surprisingly (to me at least), the answer is no. You
don't have to allocate the hEvent, but there are a couple of caveats. First,
you must set the field to NULL. Second, you must now poll for the results by
calling GetOverlappedResults() instead of doing
a more efficient wait by calling WaitForSingleObject().