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

📄 client.cpp

📁 COM+ Programming: A Practical Guide Using Visual C++ and ATL by Pradeep Tapadiya
💻 CPP
字号:
// Client.cpp : Defines the entry point for the application.
//

#include "stdafx.h"
#import "..\SingletonExample\SingletonExample.tlb"
using namespace SINGLETONEXAMPLELib;

void sub1();
void sub2();

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
 	CCPLComInitializer init;

	try {
		sub1();
		sub2();
	}catch(_com_error& e) {
		::MessageBox(NULL, CPLGetError(e), NULL, MB_OK);
	}

	return 0;
}

void sub1()
{
	IMySingletonPtr spSingleton;
	HRESULT hr = spSingleton.CreateInstance(__uuidof(MySingleton));
	if (FAILED(hr)) {
		_com_issue_error(hr);
	}
	spSingleton->LicenseKey = "MyMagicNumber1234";
}

void sub2()
{
	IMySingletonPtr spSingleton;
	HRESULT hr = spSingleton.CreateInstance(__uuidof(MySingleton));
	if (FAILED(hr)) {
		_com_issue_error(hr);
	}
	::MessageBox(NULL, spSingleton->LicenseKey, _T("License Key"), MB_OK);

}



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -