muchas gracias al fin lo conseguí, se demora un poco, pero no importa. muchas gracias
Nelson
para que fuera compatible con XE3 lo hice asi.
Código Delphi
[-]procedure DumpFile(aFileName:TFileName; SG: TStringGrid; const BPF: Word);
var
c, i, r, b : Integer;
Ascii: String;
Aux: Byte;
Col : Integer;
begin
with TMemoryStream.Create do
try
LoadFromFile(aFileName);
SG.ShowHeader := False;
SG.ShowHorzLines := False;
SG.ShowVertLines := False;
for i := 1 to BPF + 2 do
SG.AddObject(TStringColumn.Create(nil));
SG.RowCount:= Size div BPF;
for Col := 0 to SG.ColumnCount - 1 do
begin
if (Col = 0) then
SG.Columns[Col].Width := 80;
if (Col <> SG.ColumnCount - 1) and (Col <> 0) then
SG.Columns[Col].Width := 30;
if (Col = SG.ColumnCount - 1) then
SG.Columns[Col].Width := SG.Canvas.TextWidth('X') * BPF;
end;
SG.Cells[0,0]:= 'Offset(h)';
SG.Cells[SG.ColumnCount-1,0]:= 'ASCII';
for i:= 0 to BPF-1 do
begin
SG.Cells[i+1,0]:= IntToHex(i,2);
end;
Seek(0, soBeginning);
c:= 0;
r:= 1;
b := 0;
while c < Size do
begin
Application.ProcessMessages;
if CancelProcess then
begin
CancelProcess := False;
Break;
end;
SG.Cells[0, r]:= Format('%s',[IntToHex(c, 8)]);
Ascii:= EmptyStr;
i:= 0;
while (i < BPF) do
begin
Read(Aux, SizeOf(Byte));
SG.Cells[i+1,r]:= IntToHex(Aux,2);
if Aux = 0 then Aux := 46;
Ascii:= Ascii + Chr(Aux);
Inc(i);
if (b < Size) then Inc(b);
end;
SG.Cells[SG.ColumnCount-1,r]:= Format('%s',[Ascii]);
Inc(c, BPF);
Inc(r);
end;
finally
Free;
end;
end;
procedure SaveDump(aFileName:TFileName; SG: TStringGrid);
var
c,r: Integer;
s: String;
begin
with TStringList.Create do
try
for r:= 0 to SG.RowCount-1 do
begin
s:= '';
for c:= 0 to SG.ColumnCount-1 do s:= s + SG.Cells[c,r] + ' ';
SetLength(s,Length(s)-1);
Add(s);
end;
SaveToFile(aFileName);
finally
Free;
end;
end;
procedure TForm12.Button25Click(Sender: TObject);
begin
with SaveDialog1 do
begin
Filter:= '*.txt';
DefaultExt:= '*.txt';
if Execute then
SaveDump(FileName, StringGrid1);
end;
end;
procedure TForm12.Button6Click(Sender: TObject);
var
valor:string;
begin
valor:='16';
with OpenDialog1 do
begin
Filter:= '*.*';
if Execute then
begin
Caption:= FileName;
DumpFile(FileName, StringGrid1,
StrToInt(valor));
end;
end;
end;
procedure TForm12.Button26Click(Sender: TObject);
begin
CancelProcess := True;
end;
gracias a
Ecfisa y Nelson.