class CRS232Port
{
private:
HANDLE m_hCommPort; //串行口的句柄
//char m_RecvBuf[BUFFER_SIZE], m_SendBuf[BUFFER_SIZE];
//UINT m_RecvPTR;
//CEvent SendEvent( 0, true, 0, 0), RecvEvent( 0, true, 0, 0);
OVERLAPPED m_SendOV, m_RecvOV;
public:
CRS232Port(void);
~CRS232Port(void);
// 获取所有的COM端口号,保存在pPortList中
void GetAllComPort(CString* pPortList);
// 将char型转换成unicode,输入为pchIn, 输出为pstrOut
static int CharToUnicode(char* pchIn, CString* pstrOut);
// 初始化端口
bool InitPort(CString strPort, int iBaudRate, int iByteSize, int iParity, int iStopBits);
// 发送数据, 入口为要发送的数据的长度
void SendFile(ULONG SendLen, char sendBuf[]);
// 设置发送数据
//void SetSendBuf(char sendBuf[]);
bool ReadData(CString* ShowStr);
};
1