就剩调用这个COM了,很普通的一个调用。几个步骤介绍一下: 1. 初始化COM环境(系统的) 2. 通过ID创建接口实例 3. 调用接口 4. 释放接口实例 5. 清理COM环境(系统的) 实现代码如下: 01.#include "stdafx.h" 02.#include <windows.h> 03.#include <conio.h> 04.#include "..//mycom//mycom.h" 05.#include <iostream> 06.using namespace std; 07.int _tmain(int argc, _TCHAR* argv[]) 08.{ 09. //初始化COM库 10. HRESULT hr = ::CoInitialize(0); 11. ITest* ptest = NULL; 12. hr = CoCreateInstance(CLSID_MyCOM, NULL, CLSCTX_INPROC_SERVER, IID_ITest, (void**)&ptest); 13. if(SUCCEEDED(hr)) 14. { 15. int value = 0; 16. hr = ptest->Add(1, 2, &value); 17. if(SUCCEEDED(hr)) 18. cout << "1 + 2 = " << value << endl; 19. } 20. ptest->Release(); 21. ::CoUninitialize(); 22. _getch(); 23. return 0; 24.} 本文来自优快云博客,转载请标明出处:http://blog.youkuaiyun.com/zhoujianhei/archive/2010/07/30/5777549.aspx