质
质数
Unregistered / Unconfirmed
GUEST, unregistred user!
象 UltraEdit-32 读取文件一样,能够以16进制文本的形式显示出来,求最快的算法!
下面的算法很慢。。。
procedure TForm1.Button1Click(Sender: TObject);
var
f : file of byte;
fs,i : Integer;
bytes : array of byte;
tempstr : string;
begin
if OpenDialog1.Execute then
begin
tempstr := '';
assignfile(f,OpenDialog1.FileName);
reset(f);
fs:=filesize(f);//返回的字节数正确
SetLength(bytes,fs);
i := 0;
repeat
seek(f,i);
read(f,bytes);
tempstr := tempstr + ' ' + IntToHex(Bytes,2);
Inc(i);
until i >= fs;
tempstr := Copy(tempstr,2,Length(tempstr));
Memo1.Text := tempstr;
CloseFile(f);
end;
end;
下面的算法很慢。。。
procedure TForm1.Button1Click(Sender: TObject);
var
f : file of byte;
fs,i : Integer;
bytes : array of byte;
tempstr : string;
begin
if OpenDialog1.Execute then
begin
tempstr := '';
assignfile(f,OpenDialog1.FileName);
reset(f);
fs:=filesize(f);//返回的字节数正确
SetLength(bytes,fs);
i := 0;
repeat
seek(f,i);
read(f,bytes);
tempstr := tempstr + ' ' + IntToHex(Bytes,2);
Inc(i);
until i >= fs;
tempstr := Copy(tempstr,2,Length(tempstr));
Memo1.Text := tempstr;
CloseFile(f);
end;
end;