//一个字符一个字符的从串口读取数据
tch = 0;
pPtr = szText;
for (i = 0; i < sizeof (szText)-sizeof (TCHAR); i++) {
while (!ReadFile (hComPort, pPtr, 1, &cBytes, NULL))
if (hComPort == INVALID_HANDLE_VALUE)
return FALSE;
// This syncs the proper byte order for Unicode.
tch = (tch << 8) & 0xff00;
tch |= *pPtr++;
if (tch == TEXT ('\n'))
break;
}
*pPtr++ = 0; // Avoid alignment probs by addressing as bytes.
*pPtr++ = 0;
// If out of byte sync, move bytes down one.
if (i % 2) {
pPtr = szText;
while (*pPtr || *(pPtr+1)) {
*pPtr = *(pPtr+1);
pPtr++;
}
*pPtr = 0;
}
SendDlgItemMessage (hwnd, IDC_EDITTEST, EM_REPLACESEL, 0,
(LPARAM)szText);