m_bConnected=TRUE; return TRUE; } DWORD CSerial::WritePort(TCHAR *buf,DWORD dwCharToWrite) { BOOL fWriteState; DWORD dwBytesWritten; //写入数据 fWriteState=WriteFile(hPort,buf,dwCharToWrite*sizeof (TCHAR),&dwBytesWritten,NULL); if(!fWriteState) { //不能写数据 MessageBox(NULL,TEXT("Can't Write String to Comm"),TEXT("Error"),MB_OK); dwBytesWritten=0; } return dwBytesWritten; } DWORD WINAPI ReadPortThread(LPVOID lpvoid) { BOOL fReadState; DWORD dwCommModemStatus; DWORD dwLength; COMSTAT ComStat; DWORD dwErrorFlags; while (hPort != INVALID_HANDLE_VALUE) { //等待串口的事件发生 WaitCommEvent (hPort, &dwCommModemStatus, 0); if (dwCommModemStatus & EV_RXCHAR) { ClearCommError(hPort,&dwErrorFlags,&ComStat); 希望看到更多更经典的开发技巧,请随时刷新《开发特区》栏目。 |
正在阅读:VC学习:Windows CE下的串口通讯类VC学习:Windows CE下的串口通讯类
2004-02-14 09:34
出处:PConline
责任编辑:linjixiong
键盘也能翻页,试试“← →”键