查找 IMAPI2 COM 对象的 UUID/标头或让__uuidof在 mingw 上工作
finding uuid's/headers for imapi2 com objects or get __uuidof to work on mingw
我正在尝试从mingw项目访问imapi2com对象。我试图效仿visual studio的例子。我在微软SDK 7.1中找到了imapi2头文件,但它们似乎没有uuid。我看到的例子是在创建对象时使用__uuidof来查找uuid。这样的:
CoCreateInstance(__uuidof(MsftDiscMaster2), NULL, CLSCTX_INPROC_SERVER, __uuidof(IDiscMaster2), (void**) &m_discMaster);
但是我总是得到一个错误因为__uuidof是
对_GUID的未定义引用__mingw_uuidof () .
但是__mingw_uuidof被定义为…
#define __CRT_UUID_DECL(type,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8)
extern "C++" {
template<> inline const GUID &__mingw_uuidof<type>() {
static const IID __uuid_inst = {l,w1,w2, {b1,b2,b3,b4,b5,b6,b7,b8}};
return __uuid_inst;
}
template<> inline const GUID &__mingw_uuidof<type*>() {
return __mingw_uuidof<type>();
}
}
…在_mingw.h中,从"#define __uuidof(type) __mingw_uuidof<__typeof(type)>()"开始的几行
为什么__mingw_uuidof的mingw定义不起作用?
是否有办法在sdk头文件中找到像DiscMaster这样的imapi对象的uid ?或者我需要得到其他头文件。
谢谢
COM接口通常由。idl文件定义,它们使用midl从这些文件生成。h文件。因此,要查找CLSID或IID值,请搜索idl文件。在本例中是imapi2。Idl有您需要的向导,它已经被用来生成一个imapi2.h文件:
class DECLSPEC_UUID("2735412E-7F64-5B0F-8F00-5D77AFBE261E")
MsftDiscMaster2;
微软编译器中的__uuidof扩展通过编译器特定的declspec语句读取附加到类或结构中的编译器特定数据。您可以使用:
struct declspec(uuid("{......}")) IMyInterfaceType;
所以上面的DECLSPEC_UUID行是将那个guid附加到类上。
您从mingw中给出的示例代码给出了一个模板函数,如果您首先使用__CRT_UUID_DECL设置类型,则该函数将返回给定类型的uuid。可能他们有一个自动调用的系统,但没有显示出来。鉴于我在您的示例中看到的,要使__uuidof为给定的coclass工作,您需要添加:
__CRT_UUID_DECL(MsftDiscMaster2, 0x2735412e, 0x7f64, 0x5b0f, 0x8f, 0x00, 0x5d, 0x77, 0xaf, 0xbe, 0x26, 0x1e);
在该语句之后,您将有一个__uuidof(MsftDiscMaster2)
的定义,它将返回正确的uid。
- 在VS代码中交叉编译Windows与Linux上的MinGW的SDL程序
- 如何将C++中的库和头与MinGW一起使用
- 为什么与常规GCC不同,即使有"学究性错误",MinGW-GCC也能容忍丢失的返回类型
- 无法在windows上使用mingw将sqlite3与c连接
- MinGw 无法从 cmake 编译测试文件
- MSYS2 MinGW程序包中缺少grpc_cpp_plugin协议
- Mingw-64 在构建和安装后不会编译 openCV 代码
- 安装MinGW后C++编译器不起作用?
- 当我尝试通过 mingw 使用 CMake 和 SFML 库编译项目时出错
- 如何在 Linux for Windows 上通过 MinGW 构建静态 ICU 的 Boost
- 使用 MinGW 在 Windows 上安装 GMP 时出错
- VSCode - C++ - MinGW 编译器的问题
- C++:如何在Windows 10上使用编译器MinGW 9.2.0安装OpenCV
- MINGW - 正确运行函数所需的 cdecl
- 尝试在Windows上执行C++时出错(通过MinGW编译)
- 分段 Linux Ubuntu 中的 g++ 错误,但在 Windows 中的 g++/MingW 中,在 C++ 中打
- SFML 库 - 在 MinGW 构建期间未找到错误
- 使用 MinGW 在 Windows 上构建 GLEW 时遇到问题
- 如何使用命令提示符、记事本和 MinGW 使用主文件、头文件和实现文件编译C++程序?
- 如何构建一个 setup.py 来编译C++使用 Python、pybind11 和 Mingw-w64 的扩展?