主题:[讨论]WaitCommEvent();函数返回 FALSE 的原因?
请问各位大虾, WaitCommEvent();函数返回 FALSE 的原因?
if(!WaitCommEvent(pRData->hComm, &dwMask, &os)) // 重叠操作
{
if(GetLastError()==ERROR_IO_PENDING)
// 无限等待重叠操作结果
GetOverlappedResult(pRData->hComm, &os, &dwTrans, TRUE);
else
{
CloseHandle(os.hEvent);
return (UINT)-1;/// 函数执行 进入这里的原因?
}
}
else
{
if((dwMask & EV_DSR)==EV_DSR)
{
::PostMessage(pRData->hwnd,UM_REVENT,EV_RXCHAR,0);
}
WaitForSingleObject(pRData->m_pMsgEObject, INFINITE);
ResetEvent(pRData->m_pMsgEObject);
continue;
}
}
if(!WaitCommEvent(pRData->hComm, &dwMask, &os)) // 重叠操作
{
if(GetLastError()==ERROR_IO_PENDING)
// 无限等待重叠操作结果
GetOverlappedResult(pRData->hComm, &os, &dwTrans, TRUE);
else
{
CloseHandle(os.hEvent);
return (UINT)-1;/// 函数执行 进入这里的原因?
}
}
else
{
if((dwMask & EV_DSR)==EV_DSR)
{
::PostMessage(pRData->hwnd,UM_REVENT,EV_RXCHAR,0);
}
WaitForSingleObject(pRData->m_pMsgEObject, INFINITE);
ResetEvent(pRData->m_pMsgEObject);
continue;
}
}