慕桂英3389331
12345678910111213141516171819202122232425262728293031323334写6个 异步延迟等待1秒肯定能写完 然后判断 重叠结构判断写的数据 跟 真正写的数据 是不是相等 bool CComControl::Send(BYTE* pBuff,DWORD dwBytesSend){ if (!PortOpened()) return false; BOOL wRes; DWORD dwBytesW; wRes = WriteFile(m_hCom,pBuff,dwBytesSend,&dwBytesW,&m_ovWrite); if (!wRes) { if (GetLastError() == ERROR_IO_PENDING) { WaitForSingleObject(m_ovWrite.hEvent,1000); wRes = GetOverlappedResult(m_hCom,&m_ovWrite,&dwBytesW,false); if (!wRes || dwBytesW !=dwBytesSend) { ClearInOut(); return false; } } else { ClearInOut(); return false; } } return true;}
当年话下
写6个 异步延迟等待1秒肯定能写完 然后判断 重叠结构判断写的数据 跟 真正写的数据 是不是相等bool CComControl::Send(BYTE* pBuff,DWORD dwBytesSend){if (!PortOpened()) return false;BOOL wRes;DWORD dwBytesW;wRes = WriteFile(m_hCom,pBuff,dwBytesSend,&dwBytesW,&m_ovWrite);if (!wRes){if (GetLastError() == ERROR_IO_PENDING){WaitForSingleObject(m_ovWrite.hEvent,1000);wRes = GetOverlappedResult(m_hCom,&m_ovWrite,&dwBytesW,false);if (!wRes || dwBytesW !=dwBytesSend){ClearInOut();return false;}}else{ClearInOut();return false;}}return true;}