文件名称:Serial-VC++6
文件大小:3KB
文件格式:RAR
更新时间:2015-01-10 06:34:33
VC串口,VC串口编程,
VC++6.0下的串口编程,经典代码。 DCB dcb; COMMTIMEOUTS TimeOuts; CString name=""; if(port>0&&port<10) { name.Format("COM%d",port); } else if(port>=10) { name.Format("\\\\.\\COM%d",port); } CString errLog=""; hCom=CreateFile(name,GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL|FILE_FLAG_OVERLAPPED,NULL); if(INVALID_HANDLE_VALUE==hCom) { // errLog.Format("create com file faild,port=%s\r\n",name); // SysFileWrite(errLog); return FALSE; } if(!GetCommState(hCom,&dcb)) { // errLog.Format("GetCommStateeate faild,port=%s\r\n",name); // SysFileWrite(errLog); return FALSE; }
【文件预览】:
Serial.h
Serial.cpp