你可以根据要显示的包定义一个结构体,把收到的包值给结构体就可以了,注意包的开始位置;或者你可以自己硬解包:
procedure ShowData(buffer_length: integer;var buffer: array of BYTE; ACaption: string);
var
textlist: TStringList;
str1: string;
i, c, rlen: integer;
begin
textlist:=TStringList.Create;
textlist.Add('buffer_length='+IntToStr(buffer_length));
if buffer_length<512 then rlen:=16
else rlen:=32;
for i:=0 to buffer_length div rlen do
begin
str1:=IntToStr(i)+':';
for c:=0 to rlen-1 do
begin
if i*rlen+c<buffer_length then
str1:=str1+' '+ByteToHex(buffer[i*rlen+c]);
end;
textlist.Add(str1);
end;
Application.MessageBox(PChar(textlist.Text),PChar(ACaption),MB_OK);
textlist.Destroy;
end;