Solved

File Comparison

Posted on 2000-04-27
4
212 Views
Last Modified: 2012-05-04
How do I perform a binary file comparison (like the one in DOS [FC]) and direct the output to a file using delphi 5.
0
Comment
Question by:eldraco
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 9

Expert Comment

by:ITugay
ID: 2758432
Hi
The working sample is bellow.

-----
uses ... , ShellApi, ...

procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
   ShellExecute(handle,'open','command','/c fc c:\autoexec.bat c:\autoexec.dos > c:\result.txt',nil,SW_HIDE);
end;

-----
Igor.
0
 
LVL 7

Expert Comment

by:Motaz
ID: 2761452
But there is one problem. How did you know that the compression is finished!

Motaz
0
 
LVL 1

Expert Comment

by:new_x
ID: 2763341
Listening
0
 
LVL 7

Accepted Solution

by:
God_Ares earned 100 total points
ID: 2763555
I think this is what you need...
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: 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);

  s1.free;
  s2.free;
end;

end.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
HTML text in the body of an email (delphi code) 12 253
Multiple image collision 13 106
FMX and jaudiotracker playing memory stream 29 108
Way to create an iPhone app for my customers 8 89
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question