在 Win32 下 Serial Port 的通訊 以下的東西是我在閱讀 "Communications Programming for Windows 95" 時做的一點 筆記, 所以在 topic 上大致上都和這書上的第三章一樣. 一些 structure 和 API 的 宣告都是 copy from VC 5.0 的 on-line help. 這些東西主要談的是如何在 Win32 的平台下對 serial port 的通訊. 可能可以帶來 幫助的是那些了解 serial port 的通訊, 但是不清楚在 Win32 平台究竟有那些 API 可用的 programer (就像我? :p) 我只是做做整理罷了, 更清楚的內容可能要再翻翻 on-line help 或是書本. 如果你要嘗試在 Win32 下做像是對 modem 做控制(例如撥 號, 通訊)的程式, 但是對於 serial port 並不了解, 那你應該再去找一本有講到這 些東西的書看看. 開啟一個 Serial Port 利用一般開啟檔案的 CreatFile() 即可開啟 serial port device HANDLE CreateFile( LPCTSTR lpFileName, // pointer to name of the file DWORD dwDesiredAccess, // access (read-write) mode TES lpSecurityAttributes, // poin DWORD dwShareMode, // share mode LPSECURITY_ATTRIB Uter to security attributes DWORD dwCreationDistribution, // how to create e to file with attributes to copy ); DWORD dwFlagsAndAttributes, // file attributes HANDLE hTemplateFile // hand l 用 CreateFile() API. lpFileName 為 "COM1" 或是 "COM2" dwDersiredAccess 一般為 GENER...