var
Form1: TForm1;
viewstring:string;
i:integer;
strInput,strOutput : string;
implementation
{$R *.dfm}
procedure TForm1.FormShow(Sender: TObject);
begin
comm1.StartComm;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
comm1.StopComm;
end;
procedure TForm1.Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
begin
SetLength(strInput, BufferLength);
Move(Buffer^, PChar(StrInput)^, BufferLength);
Mm_1.lines.add(StrInput);
Mm_1.lines.add('');
{ if (AnsiContainsText(StrInput,'Ctrl') and (i = 0)) then
begin
strOutput := '#17#66';
if comm1.WriteCommData(@strOutput,Length(strOutput)) = true then
i := 1
else
begin
msg.MessageDlg('数据传送失败,请重启被测产品!',mtinformation,[mbok],1);
i := 0;
exit;
end;
end;}
if AnsiContainsStr(StrInput,'ENTER') then
begin
sleep(1000);
comm1.WriteCommData(pchar(chr(26)),length(chr(26)));
end;
end;
Project f1.exe raised exception class EAccessViolation with message 'Access violation at address
00402955 in module 'f1.exe'.Read of address 00000020'.Process stopped. Use Step or Run to continue.