5,388
社区成员
发帖
与我相关
我的任务
分享
procedure TForm1.Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
var
s:string;
i:Word;
p,pData:PByte;
begin
GetLocalTime(st);
s:='';
GetMem(pData,BufferLength);
Move(Buffer^, PByte(pData)^, BufferLength);
p:=pData;
i:=0;
s:='';
while i<BufferLength do
begin
s:=s+UpperCase(IntToHex(p^,2));
inc(p);
inc(i);
end;
memo1.Lines.Add(s+DateTimetostr(now()));//用16进制格式返回接收到的数据
end;