作者:
sakido (佐米)
2014-10-03 00:00:16因為我是接手別人寫好的程式,才翻了些書就開始改,所以可能很多基礎沒有打好。
問題是這樣的,在開啟COM時,COM1~9都沒有問題。
但在COM10或更大的數字以上時卻會產生錯誤。
上網google了很久,大部分都找到說是CreateFile將裡面的COMx改成////.//COMx
但是我手上的程式完全沒有用到這一段,看到比較相關的似乎是用TComPortNumber
Comm1->CommPort=TComPortNumber(ComPort->ItemIndex);
我在這邊試著做一些改變,但徒勞無功。
雖然有註解,但我還是不太了解網路上找到的這段。
CreateFile(
"//.//COM10", // address of name of the communications device
fdwAccess, // access (read-write) mode
0, // share mode
NULL, // address of security descriptor
OPEN_EXISTING, // how to create
0, // file attributes
NULL // handle of file with attributes to copy
);
關於開啟COM10~不知道有沒有哪位大大願意解釋一下,謝謝。