📄 comclient.cpp
字号:
// COMClient.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#import "../DotNetComponent/bin/debug/DotnetComponent.tlb"
using namespace std;
using namespace DotnetComponent;
int _tmain(int argc, _TCHAR* argv[])
{
HRESULT hr;
hr = CoInitialize(NULL);
try
{
IWelcomePtr spWelcome;
hr = spWelcome.CreateInstance("Wrox.DotnetComponent"); // CoCreateInstance()
cout << spWelcome->Greeting("Bill") << endl;
IMathPtr spMath;
spMath = spWelcome; // QueryInterface()
long result = spMath->Add(4, 5);
cout << "result:" << result << endl;
}
catch (_com_error& e)
{
cout << e.ErrorMessage() << endl;
}
CoUninitialize();
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -