{函数} function BytestoHexString(ABytes: TBytes; len: Integer): AnsiString; begin SetLength(Result, len*2); BinToHex(@ABytes[0], PAnsiChar(Result), len); end; {测试} procedure TForm1.FormCreate(Sender: TObject); var bs: TBytes; rStr: AnsiString; begin bs := BytesOf('ABCDEFG'); rStr := BytestoHexString(bs, Length(bs)); ShowMessage(rStr); //41424344454647 end;