ReadFile Return Value
C / C++ / MFC
1
Posts
1
Posters
0
Views
1
Watching
-
Hi. Can i know the return value of ReadFile when a timeout occurs, if the commtimeout structure was previously set? I am writing a simple program that reads the serial port for characters arriving. Anyone can recommend a better option than the one i use? Target device is WindowCE, using embedded Visual C++ 3.0 bool WaitForChar(unsigned char character,DWORD dwTimeout) { DWORD dwTimeStart,dwRead; BYTE in[2]; dwTimeStart = GetTickCount(); while((GetTickCount() - dwTimeStart) < dwTimeout) { if(ReadFile(hPort,in,1,&dwRead,NULL)) { if(dwRead != 0) { if(in == character) return TRUE; } } else return FALSE; } return FALSE; }