在C中使用CoGetClassObject() - 访问COM对象接口

Aar*_*ron 2 c c++ windows com

有关访问应用程序接口的说明,无需使用普通 C/C++ :

  • MFC
  • ATL
  • WTL

基本上,我想使用COM对象.

工作示例源代码或指南 - 使用(功能)COM对象,而不是创建COM服务器.

问候

180*_*ION 5

以下是普通C++中的一个简单示例:

CoInitialize(NULL); // absolutely essential: initialize the COM subsystem
IMyInterface* pIFace;
// create the object and obtain a pointer to the sought interface
CoCreateInstance(CLSID_MyObject, NULL, CLSCTX_ALL, IID_IMyInterface, &pIFace);
pIFace->MethodIReallyNeed(); // use the object
pIFace->Release(); // free the object
CoUninitialize(); // cleanup COM after you're done using its services
Run Code Online (Sandbox Code Playgroud)

从这里复制:COM基础知识