//SPCOMM控件
procedure TForm1.FormCreate(Sender: TObject);
begin //初始化
comm1.startcomm;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
sbuf:array[1..4] of byte;
begin //发送
sbuf[1]:=byte($61); //帧头
sbuf[2]:=byte($00); //命令号
sbuf[3]:=byte($FF);
sbuf[4]:=byte($61); //帧尾
if comm1.writecommdata(@sbuf,4)=false then application.MessageBox('发送失败','COM1',1);
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
comm1.StopComm;
end;