给一段我用过的代码,串口组件是MSComm://命令设置相当于你的 03 03 00 01 00 03procedure COMM_REQB;var COMM_REQBbuff : array[0..6] of byte; xx :byte; loopi:integer;begin xx:=0; COMM_REQBbuff[0] :=$02; COMM_REQBbuff[1] :=$00; COMM_REQBbuff[2] :=$03; COMM_REQBbuff[3] :=$05; COMM_REQBbuff[4] :=$00; COMM_REQBbuff[5] :=$00; for loopi:= 0 to 5 do begin xx := xx xor COMM_REQBbuff[loopi]; end; COMM_REQBbuff[6] :=xx; FillChar(ApduSendDataBuff, High(ApduSendDataBuff), 0); //StrCopy(@ApduSendDataBuff, @COMM_REQBbuff); for loopi := 0 to 6 do begin ApduSendDataBuff[loopi] := COMM_REQBbuff[loopi]; end; XorLen := 6;end;//数据送串口函数function serialsend(mscomm:TMSComm):Integer;var //errmessage:string; recvlen:Integer; i: integer; reData:array of Variant; restr: string; StrSend: string; TxBuff: OleVariant;beginif mscomm.PortOpen = false then mscomm.PortOpen := True; try StrSend := ''; //重置它的大小,为0~n,int为n的类型。 //varByte为TxBuff每一个元素的类型。 TxBuff := VarArrayCreate([0, 255],varByte); //填充元素其中ApduSendDataBuff为你定义的一个固定数组,其中有你要发的数据 StrSend := ''; for i := 0 to XorLen do begin TxBuff := ApduSendDataBuff; StrSend := StrSend + IntToHex(ApduSendDataBuff, 2) + ' '; end; WriteLog('发送命令:' + StrSend); mscomm.Output:=TxBuff;//发送数据 XorLen := 0; FillChar(ApduRecvDataBuff, High(ApduRecvDataBuff) + 1, 0); FillChar(ApduSendDataBuff, High(ApduSendDataBuff) + 1, 0); Sleep(300); if mscomm.InBufferCount > 0 then begin redata := mscomm.Input; // 接收数据 for i := 0 to vararrayhighbound(redata,1) do begin ApduRecvDataBuff := Integer(redata); restr := restr + IntToHex(Integer(redata), 2) + ' '; end; WriteLog('接收数据:' + restr); end else begin WriteLog('接收数据:' + restr); Result := 0; Exit; end; XorLen := 0;