首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ Builder >

在2010下使用的串口例子

2012-03-05 
求一个在2010下使用的串口例子原来的MSCOMM不行。只能在BCB6下运行。#include MSCommLib_TLB.hTCOMIMSComm

求一个在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__) 

热点排行