利用MsComm32实现的:
implementation
{$R *.DFM}
//初始化
procedure TForm1.FormCreate(Sender: TObject);
begin
Mscomm1.PortOpen:=true;
Mscomm1.InputLen:=0;
Mscomm1.RThreshold:=5;
MsComm1.InputMode:=comInputModeText;
ReData:='';
end;
//发送数据
procedure TForm1.BitBtn1Click(Sender: TObject);
var
s1:string;
StringCount,i:integer;
begin
Mscomm1.InBufferCount:=0;
MsComm1.Output:='dfdsfsd';
end;
//接收数据
procedure TForm1.MSComm1Comm(Sender: TObject);
begin
Case MsComm1.CommEvent of
2:
ReData:=MsComm1.Input+ReData;
end;
end;