📄 client.cpp
字号:
#define _WIN32_DCOM
#include <windows.h>
#include <stdio.h>
#include <iostream.h>
#include "Component\component.h"
void main()
{
CoInitialize(NULL);
IBindCtx* pBindCtx;
CreateBindCtx(0, &pBindCtx);
ULONG eaten;
IMoniker* pMoniker;
// Replace MyHost with machine name on which the component is registered
OLECHAR string[] = L"host:MyHost!clsid:10000013-0000-0000-0000-000000000001";
HRESULT hr = MkParseDisplayName(pBindCtx, string, &eaten, &pMoniker);
if(FAILED(hr))
cout << "MkParseDisplayName failed" << endl;
IPrimeFactory* pPrimeFactory;
pMoniker->BindToObject(pBindCtx, NULL, IID_IPrimeFactory, (void**)&pPrimeFactory);
IPrime* pPrime;
pPrimeFactory->CreatePrime(11, &pPrime);
int next;
pPrime->GetNextPrime(&next);
cout << next << endl;
OLECHAR* moniker_name;
pMoniker->GetDisplayName(pBindCtx, NULL, &moniker_name);
wprintf(L"DisplayName is %s\n", moniker_name);
CoTaskMemFree(moniker_name);
pPrime->Release();
pPrimeFactory->Release();
pBindCtx->Release();
pMoniker->Release();
CoUninitialize();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -