串口工具收发,代码简单明了,适合初学者,vs void CSerialTestDlg::OnBnClickedButton1() { // TODO: Add your control notification handler code here CString str,strCOM,strBaud; int com,baud; GetDlgItemText(IDC_BUTTON1,str); // GetDlgItemText(IDC_COMBO_COM,strCOM); com=m_cmb_com.GetCurSel()+1; GetDlgItemText(IDC_COMBO_BAUD,strBaud); baud = _ttoi(strBaud); if(str==_T("打开串口")) { if(m_Serial.OpenPort(this->m_hWnd,com,baud)) { m_Serial.m_OnSeriesRead = m_OnSeriesRead; //设置回调函数接口 SetDlgItemText(IDC_BUTTON1,_T("关闭串口&quo t;)); } } else if(str==_T("关闭串口")) { m_Serial.ClosePort(); SetDlgItemText(IDC_BUTTON1,_T("打开串口")); } }