procedure TForm1.Button1Click(Sender: TObject);
begin
if opendialog1.execute then fname1:=opendialog1.filename;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if opendialog2.execute then fname2:=opendialog2.filename;
end;
procedure TForm1.Button3Click(Sender: TObject);
var s1,s2:Tfilestream;
i,j:integer;
a,b:byte;
begin
s1:=tfilestream.Create(fname1,fmOpenRead);
s2:=tfilestream.Create(fname2,fmOpenRead);
if s1.Size > s2.size then i:=s2.size else i:=s1.size;
For j:=1 to i-1 do
Begin
s1.Read(a,1);
s2.Read(b,1);
if a<>b then memo1.lines.add(inttohex(j,6)+' '+inttohex(a,2)+' '+inttohex(b,2));
End;
if s1.Size > s2.size then memo1.Lines.add(fname1+' is lager than '+fname2);
if s1.Size < s2.size then memo1.Lines.add(fname2+' is lager than '+fname1);
code could be optimized..
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Memo1: TMemo;
OpenDialog1: TOpenDialog;
OpenDialog2: TOpenDialog;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
fname1,fname2:string;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender
begin
if opendialog1.execute then fname1:=opendialog1.filena
end;
procedure TForm1.Button2Click(Sender
begin
if opendialog2.execute then fname2:=opendialog2.filena
end;
procedure TForm1.Button3Click(Sender
var s1,s2:Tfilestream;
i,j:integer;
a,b:byte;
begin
s1:=tfilestream.Create(fna
s2:=tfilestream.Create(fna
if s1.Size > s2.size then i:=s2.size else i:=s1.size;
For j:=1 to i-1 do
Begin
s1.Read(a,1);
s2.Read(b,1);
if a<>b then memo1.lines.add(inttohex(j
End;
if s1.Size > s2.size then memo1.Lines.add(fname1+' is lager than '+fname2);
if s1.Size < s2.size then memo1.Lines.add(fname2+' is lager than '+fname1);
s1.free;
s2.free;
end;
end.