type
THexConversion=class(TConversion)
public
function ConvertReadStream(Stream:TStream;BufferChar;
BufSize:Integer):Integer;override;
end;
function THexConversion.ConvertReadStream(Stream:TStream;BufferChar;Bufsize:Integer):Integer;
var
s:string;
buf:array[1..16] of char;
i,n:Integer;
begin
Result:=0;
if BufSize<=82 then Exit;
s:=Format(';%.5x ',[Stream.Position]);
n:=stream.read(buf,16);
if n=0 then Exit;
for i:=1 to n do
begin
AppendStr(s,IntToHex(ord(buf),2)+' ');
if i mod 4=0 then AppendStr(s,' ');
end;
AppendStr(s,StringOfChar(' ',62-length(s)));
for i:=1 to n do
begin
if (buf<#32)or(buf>#126) then
buf:='.';
appendstr(s,buf);
end;
appendstr(s,#13#10);
strPCopy(Buffer,s);
Result:=Length(s);
if Stream.Position and $FFFF=0 then
//MainForm.Progress(Stream.Position);
end;
procedure TMainForm.FormCreate(Sender: TObject);
begin
rich.RegisterConversionFormat('bin',THexConversion);
rich.RegisterConversionFormat('exe',THexConversion);
end;
procedure TMainForm.SpeedButton1Click(Sender: TObject);
var
fname:string;
begin
rich.Lines.clear;
application.ProcessMessages;
try
rich.lines.LoadFromFile('d:/rich.exe');
except on e:EFOpenError do
MessageDlg('Can''t open file!',mtError,[mbOk],0);
end;