The CreateFile function can create a handle to a communications resource, such as the serial port COM1. For communications resources, the dwCreationDisposition parameter must be OPEN_EXISTING, and the hTemplate parameter must be NULL. Read, write, or read/write access can be specified, and the handle can be opened for overlapped I/O. The COMM sample (TTY) demonstrates using the Win32 communications functions while maintaining a common code base with 16-bit Windows code.The program performs communications using the functions OpenFile, ReadFile, SetCommState, SetCommMask, WaitCommEvent, WriteFile, and CloseFile.The program creates a background thread to watch for COMM receiver events and posts a notification message to the main terminal window. Foreground character processing is written to the communications port.Simple TTY character translation is performed and a screen buffer is implemented for use as the I/O window.Overlapped file I/O techniques are demonstrated.http://msdn.microsoft.com/library/en-us/vcsample98/html/vcsmpserialsampleforcommunicationsdemonstration.asp
可以用writefile控制吧
因为mscomm也不支持230400波特率的
可以只用一个串口,然后接一个rs485转换器,就可接128个设备了,只需要给每个设备定义不同的地址,通讯是加以区分就行了。