Re: About Hex Editors...


Posted by Jean Claude Servaye on June 28, 2000 at 19:15:08:

In Reply to: About Hex Editors... posted by Magus on May 22, 2000 at 04:24:23:

Try this exemple, put a Memo on the form and a button
On the button click write:

var
F : File of Char;
I, Count : Integer;
A : Char;
S,T : String;
begin
AssignFile(F,'C:\Project1.exe'); //change to the file to display
Reset(F); // Open file to read
S := '';
While Not Eof(F) do begin // repeat for each byte
Read(F,A); // read a charte
Inc(Count);
If Count <= 15 then begin // we will display 16 bytes per line
T := Format('%x',[Ord(A)]); // convert to hex
If Length(T) = 1 then T := '0'+T; // padd with a 0 (it's seems that format don't work as suspected
S := S + (T)+ ' '; // save in a string
end
else begin
If Memo1.Lines.Count < 200 then Memo1.Lines.Add(S) else Break;
S := '';
Count := 0;
end;
end;
CloseFile(F) ; // close the file


Caution : a memo can't contain an illimited number of lines
end;



Related Articles and Replies: