Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For <code>GetIoCompletionPort</code> to work correctly, you need to specify a non-null pointer to a <code>ULONG_PTR</code> for it to write the 'key' value to:</p> <pre><code>ULONG_PTR key; GetQueuedCompletionStatus( completion_port, &amp;numBytes, &amp;key, &amp;po, INFINITE ); </code></pre> <p>To use <code>GetOverlappedResult</code> successfully, I believe you need to specify an event handle in the <code>OVERLAPPED</code> structure (strongly recommended in any case):</p> <pre><code>o.hEvent = CreateEvent(NULL, FALSE, TRUE, NULL); </code></pre> <p>Calling the two in succession as you were doesn't really accomplish much -- they both tell you about the same things. Though if you do call both in succession, you'll need to change the Event to be a manual-reset by changing the third parameter to <code>CreateEvent</code> to TRUE. My guess is that you were just trying both to see if you could get one to work. All things considered, I'd probably just use <code>GetQueuedCompletionStatus</code>, and leave it at that. Of course, you'll usually do more than call it once and quit. You normally call it in a loop, processing the current buffer you've read, then calling <code>ReadFile</code> again to read another buffer of info, something like this:</p> <pre><code>DWORD numBytes; LPOVERLAPPED po; while (GetQueuedCompletionStatus(completion_port, &amp;numBytes, &amp;key, &amp;po, INFINITE)) { std::cout &lt;&lt; "\rRead: " &lt;&lt; numBytes; // just to show it's set correctly. process(buffer); po-&gt;offset += sizeof(buffer); ReadFile(file, buffer, sizeof(buffer), NULL, po); } </code></pre> <p>At least in a quick test on my machine, this showed the number of bytes read correctly (<code>sizeof(buffer)</code> up to the last packet, then the remaining size of the file).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload