//---------------------------------COM2 中断方式接受--
procedure TForm1.Comm2ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
type
IArr = ^integer;
var
RevP : array [1..4096] of byte;
i : integer;
CommRevStr : String;
begin
SetLength(CommRevStr,BufferLength);
Move(IArr(buffer)^,Revp,bufferLength);
For i:=1 to BufferLength do
begin
CommrevStr := Char(Revp);
end;
Memo2.Lines[1]:=' ';
memo2.Lines[1]:=CommrevStr;
end;
//向COMM2发送一行或多行
procedure TForm1.BitBtn1Click(Sender: TObject);
var strSend: String;ok:boolean;
begin
Sleep(10);
strSend:=' ';
// for i:= 0 to Memo2.Lines.Count -1 do
// BEGIN
IF Memo2.Lines[1]<>' ' THEN
strSend:= Memo2.Lines[1];
try
//一行一行送
ok:=Comm2.WriteCommData(PChar(strSend) , Length(strSend));
except
Showmessage('Comm2发送错误');
end;
// END;
end;