以下是普通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基础知识
| 归档时间: |
|
| 查看次数: |
3782 次 |
| 最近记录: |