robot.h

来自「Visual_C++[1].NET_Bible1 Visual_C++宝典书中」· C头文件 代码 · 共 62 行

H
62
字号
// Robot.h : Declaration of the CRobot

#pragma once
#include "resource.h"       // main symbols


// IRobot
[
	object,
	uuid("9913C8F7-CE4A-4C25-A112-6AFCC4201FD5"),
	dual,	helpstring("IRobot Interface"),
	pointer_default(unique)
]
__interface IRobot : IDispatch
{
	[propget, id(1), helpstring("property BatteryLife")] HRESULT BatteryLife([out, retval] LONG* pVal);
	[propput, id(1), helpstring("property BatteryLife")] HRESULT BatteryLife([in] LONG newVal);
	[id(2), helpstring("method Speak")] HRESULT Speak([in] BSTR bstrSpeech);
};



// CRobot
[
	coclass,
	threading("apartment"),
	vi_progid("RobotServer.Robot"),
	progid("RobotServer.Robot.1"),
	version(1.0),
	uuid("3208C53E-41AF-4841-A0D3-C162FB786FAF"),
	helpstring("Robot Class")
]
class ATL_NO_VTABLE CRobot : 
	public IRobot
{
public:
	CRobot() : m_nBatteryLife(100)
	{
	}

	DECLARE_PROTECT_FINAL_CONSTRUCT()

	HRESULT FinalConstruct()
	{
		return S_OK;
	}
	
	void FinalRelease() 
	{
	}

public:

	STDMETHOD(get_BatteryLife)(LONG* pVal);
	STDMETHOD(put_BatteryLife)(LONG newVal);
private:
	long m_nBatteryLife;
public:
	STDMETHOD(Speak)(BSTR bstrSpeech);
};

⌨️ 快捷键说明

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