读书人

在2010下使用的串口例子

发布时间: 2012-03-05 11:54:02 作者: rapoo

求一个在2010下使用的串口例子
原来的MSCOMM不行。只能在BCB6下运行。
#include "MSCommLib_TLB.h"
TCOMIMSComm *comm = new TCOMIMSComm();
只能创建,却不能进行任何操作。报错。
comm->InputMode = InputModeConstants::comInputModeBinary; // 设置接收数据模式为二进制形式
comm->InputLen = 0;
编辑可以通过但不能运行。求大家帮忙。

[解决办法]
网上不少用api做的,就是用CreateFile做的,方便灵活。

C/C++ code
//Comm.h// Comm.h: interface for the CComm class.////////////////////////////////////////////////////////////////////////#if !defined(COMM_H__)#define COMM_H__BOOL OpenComm(const char* pPort, int nBaudRate=57600, int nParity=NOPARITY, int nByteSize=8, int nStopBits=ONESTOPBIT);BOOL CloseComm();int ReadComm(void* pData, int nLength);int WriteComm(void* pData, int nLength);#endif // !defined(COMM_H__) 

读书人网 >C++ Builder

热点推荐