You should check for errors and use EV_RLSD as a bit flag:
Code:
char buff[64];
DWORD dwCommEvent;
if (!SetCommMask(m_nCommPortHandle, EV_RLSD))
{
wsprintfA(buff, "LastError = %d", GetLastError());
MessageBoxA(0, buff, "SetCommMask() Failed", MB_OK);
return FALSE;
}//if
for(;;)
{
if (!WaitCommEvent(m_nCommPortHandle, &dwCommEvent, 0))
{
wsprintfA(buff, "LastError = %d", GetLastError());
MessageBoxA(0, buff, "WaitCommEvent() Failed", MB_OK);
return FALSE;
}//if
if (dwCommEvent & EV_RLSD)
{
FlushFileBuffers(m_nCommPortHandle);
break;
}//if
}//for
You should also know that using this method does not indicate what state the line is currently in - it only indicates that it has changed since the last call to WaitCommEvent() or SetCommMask().
If you need to know the actual state of the line (high or low), you can call GetCommModemStatus().
gg