Serial communication-PortClose()
I am working on a serial communication program in VC MFC, the data communication goes well.
My problem is: when I click on Cancle to close the app, it hangs, just no response. I found it resulted from" if (!CloseHandle (hCommPort))".
Does anyone know how to fix it? Any code or link will be thankful.
My code is the same as in MSDN serial communication->sample.
BOOL PortClose (HANDLE hCommPort)
{
DWORD dwError;
if (hCommPort != INVALID_HANDLE_VALUE)
{
// Close the communication port.
if (!CloseHandle (hCommPort)) <-
{
dwError = GetLastError ();
return FALSE;
}
else
{
hCommPort = INVALID_HANDLE_VALUE;
return TRUE;
}
}
connie

