如果你已經會使用SPCOMM且出現10個以上的串口問題
請改一下串口名
COM1.CommName='//./com18';
就這樣 加'//./'就行了我也不知道什麼回事.......
比如
Comm1.CommName := '//./'+ComboBox1.Text;
//./com18是windows裏邊的SymbolLinkName,這個在WINAPI裏邊就需要這
樣寫,SPCOMM的這部分的源代碼如下:
procedure TComm.StartComm;
var
hNewCommFile: THandle;
begin
// Are we already doing comm?
if (hCommFile <> 0) then
raise ECommsError.Create( 'This serial port already opened' );
hNewCommFile := CreateFile( PChar(FCommName), &
lt;------就是這裏,要加上//./
GENERIC_READ or GENERIC_WRITE,
0, {not shared}
nil, {no security ??}
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL or FILE_FLAG_OVERLAPPED,
0 {template} );
if hNewCommFile = INVALID_HANDLE_VALUE then
raise ECommsError.Create( 'Error opening serial port' );
^^^^^^^^^^^^^^^^^^^^^^^^^^^如果不是
SymbolLinkName寫法,串口號大於9這裏就出錯了