📄 iocontroller.cpp
字号:
// IoController.cpp: the implementation of a/the CIoController class
//
// This software can be offered for free and used as necessary to aid
// in your program developments.
//
// RENESAS TECHNOLOGY CORPORATION, RENESAS SOLUTIONS CORPORATION,
// and related original software developers assume no responsibility
// for any damage or infringement of any third-party's rights, originating
// in the use of the following software.
// Please use this software under the agreement and acceptance of these conditions.
//
// Copyright(C)1998(2003) RENESAS TECHNOLOGY CORPORATION AND RENESAS SOLUTIONS CORPORATION
// ALL RIGHTS RESERVED
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "IoController.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
//Construction/disappearance
//////////////////////////////////////////////////////////////////////
CIoController::CIoController()
: m_hDevice(INVALID_HANDLE_VALUE)
{
}
CIoController::~CIoController()
{
Close();
}
//A device was opened
BOOL CIoController::Open(const CString& strDevice)
{
//It opened
m_hDevice = ::CreateFile(strDevice,
GENERIC_READ | GENERIC_WRITE,
0,
0,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
0);
//I preserve the device name if it succeeds.
if (m_hDevice != INVALID_HANDLE_VALUE)
{
m_strDevice = strDevice;
return TRUE;
}
else
{
return FALSE;
}
}
//The closing of the device.
BOOL CIoController::Close()
{
//It does not do at all if a device is not opening.
if (!IsOpen())
{
return TRUE;
}
//Invalidating the handle if it succeeds it does the device name clear.
if (::CloseHandle(m_hDevice))
{
m_hDevice = INVALID_HANDLE_VALUE;
m_strDevice.Empty();
return TRUE;
}
else
{
return FALSE;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -