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

📄 automaterobot.cpp

📁 Visual_C++[1].NET_Bible1 Visual_C++宝典书中的全部源码
💻 CPP
字号:
// AutomateRobot.cpp 

#include "stdafx.h"
#include "AutomateRobot.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif

#include "CRobot.h"

CWinApp theApp;

using namespace std;

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
	CoInitialize(NULL);
	int nRetCode = 0;

	// initialize MFC and print and error on failure
	if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
	{
		_tprintf(_T("Fatal Error: MFC initialization failed\n"));
		nRetCode = 1;
	}
	else
	{
		CRobot r;
		if (r.CreateDispatch("RobotServer.Robot"))
		{
			r.put_BatteryLife(456);
			long bl = r.get_BatteryLife();
			char buf[32];
			wsprintf(buf, "BatteryLife = %d", bl);
			MessageBox(0, buf, "Msg", 0);

			r.Speak((BSTR)"Hello Automation");
		}

	}

	CoUninitialize();
	return nRetCode;
}

⌨️ 快捷键说明

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