1.同步查询方式
CreateFile( lpFileName, //串口号 %%%
dwDesiredAccess, //GENERIC_READ|GENERIC_WRITE
dwSharedMode, //0 不允许共享
lpSecurityAttributes, //NULL
dwCreationDisposition, //OPEN_EXISTING
dwFlagsAndAttributes, //FILE_ATTRIBUTE_NORMAL %%%
//FILE_FLAG_OVERLAPPED %%%重叠I/O方式时使用
hTemplateFile) //NULL
SetupComm //设置输入输出缓存大小
GetCommState //获得一DCB结构
SetCommState
ReadFile TimeProc(hwnd,uMsg,idEvent,uElapse,lpTimerFunc)
WriteFile SetTimer
CloseHandle KillTimer
2.重叠I/O方式
CreateThread
ThreadProc
CreateEvent
WaitForSingleObject
GetOverlappedResult
3.事件驱动方式
SetCommMask
建立事件线程CreateThread
ThreadProc
WaitCommEvent
WaitForSingleObject
ClearCommError