使用自由函数作为LPOVELAPPED_COMPLETION_ROUTINE
Using free function as LPOVELAPPED_COMPLETION_ROUTINE
我无法理解以下编译错误:
unsigned char buf[1000];
const DWORD maxBytes = 1000;
OVERLAPPED o;
void foo(DWORD dwErrorCode, DWORD dwNumberOfBytesTransfered, LPOVERLAPPED lpOverlapped) {
return;
}
void bar(HANDLE hFile) {
auto lambda_foo = [](DWORD dwErrorCode, DWORD dwNumberOfBytesTransfered, LPOVERLAPPED lpOverlapped){return;};
ReadFileEx(hFile, buf, 1000, &o, lambdafoo); //compiles
ReadFileEx(hFile, buf, 1000, &o, foo); //doesn't compile
}
错误是"无法将参数 5 从'void (__cdecl *( DWORD,DWORD,LPOVERLAPPED(' 转换为'LPOVERLAPPED_COMPLETION_ROUTINE'"。我使用MSVC2015。
有人可以告诉我我做错了什么吗?为什么它使用 lambda 编译但不使用相同的自由函数?
窗口中的回调对调用约定有特殊要求。Windows 提供了一个名为CALLBACK
的方便宏,用于在定义函数时指定调用约定
void CALLBACK foo(DWORD dwErrorCode, DWORD dwNumberOfBytesTransfered, LPOVERLAPPED lpOverlapped)
{
return;
}
相关文章:
- 为什么我的C#代码在调用回C++COM直到Task时会暂停.等待/线程.加入
- 两个 COM 组件中 ENUM 的重复条目
- COM 接口 c# 封送数组数组
- COM :是否可以查看是否存在对我的某个 COM 对象的进程外引用?我可以释放它吗?
- 如何读取 C++ SAFEARRAY**,该 SAFEARRAY** 是 COM 互操作的结果,其中 C# 返回值为
- 进程外 EXE 的免注册 COM
- 使用 Outlook 2016 Microsoft Store 连接到 Outlook COM
- 如何从COM模块中的函数返回字符串数组?
- 如何在C++非托管/本机 DLL 中从注册免费 COM C# 托管 DLL 创建 COM 对象
- Windows (COM) API 的行为不同,没有特定的库
- 我是否可以使用 win32 句柄以编程方式记录发送到/接收到 USB/COM 的内容
- 在传递 com 变体时运行 excel 宏崩溃
- 从 WinRT C++组件访问 COM 对象
- c++ com 如何继承 IUIAutomationPropertyChangedEventHandler 接口
- 如何将从控制台应用程序C++回调设置为C++ COM DLL
- 使用线程 C# 中的 VC++ 6.0 COM DLL
- 问题: 从 MFC 调用 C# 未托管 COM C++
- 如何调试 COM DLL
- 通过 COM 对象连接 x64 应用程序时出现问题
- 正在将IPA文件上传到diawi.com