⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 client.cpp

📁 经验交流,从网上下载的好东西望大家分享
💻 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 + -