Class Moniker Activation.cpp
上传用户:bjlvip
上传日期:2010-02-08
资源大小:744k
文件大小:1k
源码类别:
Windows编程
开发平台:
Visual C++
- #define _WIN32_DCOM
- #include <windows.h>
- #include <iostream.h>
- #include "Componentcomponent.h"
- void main()
- {
- CoInitialize(NULL);
- IMoniker* pClassMoniker;
- CreateClassMoniker(CLSID_InsideCOM, &pClassMoniker);
- IClassFactory* pClassFactory;
- BindMoniker(pClassMoniker, 0, IID_IClassFactory, (void**)&pClassFactory);
- // IBindCtx* pClassBindCtx;
- // CreateBindCtx(0, &pClassBindCtx);
- // pClassMoniker->BindToObject(pClassBindCtx, NULL, IID_IClassFactory, (void**)&pClassFactory);
- // pClassBindCtx->Release();
- ISum* pSum;
- pClassFactory->CreateInstance(NULL, IID_ISum, (void**)&pSum);
- int addition;
- pSum->Sum(23, 32, &addition);
- cout << "23 + 32 = " << addition << endl;
- pSum->Release();
- pClassFactory->Release();
- pClassMoniker->Release();
- CoUninitialize();
- }