一个通讯的问题,请通讯方面的高手帮看一看
我的程序为什么在2000下不能发送数据,但在98下可以发送
初始化部分
DCB dcb;
COMMTIMEOUTS TimeOuts;
hComDev=CreateFile("COM1",GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL|FILE_FLAG_OVERLAPPED,NULL);
if(hComDev==INVALID_HANDLE_VALUE)
{
AfxMessageBox("串口错误");
}
SetupComm(hComDev,1024,1024);
GetCommState(hComDev,&dcb);
dcb.BaudRate=CBR_9600;
dcb.fParity=NOPARITY;
dcb.ByteSize=8;
dcb.StopBits=ONESTOPBIT;
SetCommMask(hComDev,EV_ERR|EV_RXCHAR);
SetCommState(hComDev,&dcb);
TimeOuts.ReadIntervalTimeout=1000;
TimeOuts.ReadTotalTimeoutMultiplier=1000;
TimeOuts.ReadTotalTimeoutConstant=1000;
TimeOuts.WriteTotalTimeoutMultiplier=2*9600/dcb.BaudRate ;
TimeOuts.WriteTotalTimeoutConstant=25;
SetCommTimeouts(hComDev,&TimeOuts);
发送部分
bool sss;
DWORD dwToWriteLength;
DWORD dwHaveWrittenLength;
OVERLAPPED overlappedWrite;
CString str,str1,str2;
char* buf;
m_fasong.GetWindowText(str);
buf=(LPSTR)(LPCTSTR)str;
dwToWriteLength = (DWORD)str.GetLength();
COMSTAT ComStat;
DWORD dwErrorFlags;
ClearCommError(hComDev,&dwErrorFlags,&ComStat);
sss= WriteFile(hComDev,buf,dwToWriteLength,&dwHaveWrittenLength,&overlappedWrite);