faint,岂有此理...
可以用十六进制显示并存入txt文件,如下面的方法
但这绝对是一个愚蠢的主意。
-------------------------------------
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
const BUF_SIZE=1024;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
f:file of byte;
implementation
{$R *.DFM}
function Str2Hex(const data: array of byte; len: integer): string;
const
Hex:array[0..15] of char='0123456789ABCDEF';
var
i: Integer;
begin
setlength(result,length(data)*2);
for i := 0 to Len-1 do
begin
result[i*2+1]:=Hex[data shr 4];
result[i*2+2]:=Hex[data and $F];
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
NumRead:integer;
b:array[1..BUF_SIZE] of byte;
s: string;
begin
assignfile(f,'T0105.101');
Reset(f);
repeat
BlockRead(f,b,BUF_SIZE,NumRead);
if NumRead=0 then break;
s:=Str2Hex(b,NumRead); //将每个字节以16进制表示
Memo1.Lines.Add(s);
until (NumRead = 0);
closefile(f);
Memo1.Lines.SaveToFile('binfile.txt');
end;
end.