📄 client.cpp
字号:
// client.cpp
#define _WIN32_DCOM
#include <iostream.h>
#include "Component\component.h"
void main()
{
cout << "Client: Calling CoInitialize()" << endl;
CoInitialize(NULL);
// Always need a bind context
IBindCtx* pBindCtx;
CreateBindCtx(0, &pBindCtx);
// Convert the string to a moniker
ULONG eaten;
IMoniker* pMoniker;
OLECHAR string[] = L"clsid:10000013-0000-0000-0000-000000000001";
MkParseDisplayName(pBindCtx, string, &eaten, &pMoniker);
// Bind the moniker to the named object
IPrimeFactory* pPrimeFactory;
pMoniker->BindToObject(pBindCtx, NULL, IID_IPrimeFactory, (void**)&pPrimeFactory);
// Use the custom class object to create a Prime object
IPrime* pPrime;
pPrimeFactory->CreatePrime(7, &pPrime);
// Now we have a Prime object
int next_prime;
pPrime->GetNextPrime(&next_prime);
cout << next_prime << endl; // Displays 11
// Release all
pPrimeFactory->Release();
pPrime->Release();
pBindCtx->Release();
pMoniker->Release();
cout << "Client: Calling CoUninitialize()" << endl;
CoUninitialize();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -