MkParseDisplayName.cpp
上传用户:bjlvip
上传日期:2010-02-08
资源大小:744k
文件大小:1k
- #define _WIN32_DCOM
- #include <windows.h>
- #include <iostream.h>
- #include "Componentcomponent.h"
- void main()
- {
- CoInitialize(NULL);
- OLECHAR string[] = L"clsid:10000002-0000-0000-0000-000000000001";
- IBindCtx* pBindCtx;
- CreateBindCtx(0, &pBindCtx);
- ULONG eaten;
- IMoniker* pMoniker;
- HRESULT hr = MkParseDisplayName(pBindCtx, string, &eaten, &pMoniker);
- if(FAILED(hr))
- {
- cout << "MkParseDisplayName failed" << endl;
- exit(0);
- }
- IClassFactory* pClassFactory;
- pMoniker->BindToObject(pBindCtx, NULL, IID_IClassFactory, (void**)&pClassFactory);
- 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();
- pBindCtx->Release();
- pMoniker->Release();
- CoUninitialize();
- }