gpt4 book ai didi

c - 为什么给 ReadFileEx() 的回调没有收到正确的 OVERLAPPED 结构?

转载 作者:太空宇宙 更新时间:2023-11-04 01:34:39 25 4
gpt4 key购买 nike

出于某种原因,在调用 ReadFileEx 后,我的回调没有收到正确的 OVERLAPPED 结构的地址。什么会导致这种情况?

更新——例子:

#include <stdio.h>
#include <Windows.h>

void __stdcall completion_routine(
unsigned long dwErrorCode,
unsigned long dwNumberOfBytesTransfered,
OVERLAPPED *lpOverlapped)
{
printf("Overlapped = %p\n", lpOverlapped);
}

int _tmain(int argc, LPTSTR argv[])
{
HANDLE hvolume = CreateFile(
_T("C:\\Windows\\Notepad.exe"), FILE_READ_DATA,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
NULL, OPEN_EXISTING, 0, NULL);
char tempbuf[512];
OVERLAPPED tempoverlapped = { };
printf("%p\n", &tempoverlapped);
if (ReadFileEx(hvolume, tempbuf, sizeof(tempbuf),
&tempoverlapped, &completion_routine)
&& GetLastError() == ERROR_SUCCESS)
{
SleepEx(INFINITE, TRUE);
}
}

最佳答案

我忘记将 FILE_FLAG_OVERLAPPED 指定给 CreateFile

关于c - 为什么给 ReadFileEx() 的回调没有收到正确的 OVERLAPPED 结构?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16721864/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com