procedure TForm1.Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word); //接受状态是由Receivedata自动接收
var
s: string;
begin
SetLength(S, BufferLength); //接收RS232的数据并显示Memo1上。
Move(Buffer^, PChar(S)^, BufferLength);
Memo1.Lines.Add(S);
Memo1.Invalidate;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Comm1.startcomm;//创建窗体时,将comm1控件打开。
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
comm1.StopComm;//关闭窗体时,将comm1控件关闭。
end;