[問題] BCB在開啟COM10產生問題

看板C_and_CPP作者 (佐米/木子)時間11年前發表 (2014/10/02 16:00), 10年前編輯推噓3(301)
留言4則, 1人參與, 最新討論串1/2 (看更多)
因為我是接手別人寫好的程式,才翻了些書就開始改,所以可能很多基礎沒有打好。 問題是這樣的,在開啟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~不知道有沒有哪位大大願意解釋一下,謝謝。 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.138.227.152 ※ 文章網址: http://www.ptt.cc/bbs/C_and_CPP/M.1412265619.A.EEA.html

10/03 05:57, , 1F
重點
10/03 05:57, 1F

10/03 05:57, , 2F
應該是要多加" //.//"
10/03 05:57, 2F
我不太清楚要加在哪邊,我的程式碼是這一段 看起來都像是只用到數字而已? void __fastcall TForm1::Button3Click(TObject *Sender) { // if (Comm1->PortOpen) // {Comm1->PortOpen=false;} Comm1->CommPort=TComPortNumber(ComPort->ItemIndex); Comm1->RThreshold=11; //-----------default---------------- Comm1->BaudRate=br1200; Comm1->DataBits=DB8; Comm1->HwHandShaking=hhNone; Comm1->SwHandShaking=shNone; Comm1->Parity=None; Comm1->StopBits=SB1; //---------------------------------- if (Comm1->PortOpen) { Comm1->PortOpen = false; Button3->Caption="Open"; } else { Comm1->PortOpen = true; Button3->Caption="Close"; } StatusBar1->SimpleText = "Status: Link to Com"+IntToStr(ComPort->ItemIndex+1)+" 1200,8,N,1"; //COM寫入數值 }

10/03 12:29, , 3F
c
10/03 12:29, 3F

10/03 12:31, , 4F
com port的device name設為\\.\com11
10/03 12:31, 4F
額外再加這一行的意思嗎?因為1-9都沒用到 ※ 編輯: sakido (140.138.227.152), 10/03/2014 12:39:59
文章代碼(AID): #1KBNQJxg (C_and_CPP)
文章代碼(AID): #1KBNQJxg (C_and_CPP)