标签:
1、界面
2、代码
procedure TForm1.btnSelectFile01Click(Sender: TObject); begin if OpenDialog1.Execute then begin edtSelectFile01.Text := OpenDialog1.FileName; end; end; procedure TForm1.btnSelectFile02Click(Sender: TObject); begin if OpenDialog1.Execute then begin edtSelectFile02.Text := OpenDialog1.FileName; end; end; procedure TForm1.btnCompareFileClick(Sender: TObject); var ms1,ms2 :TMemoryStream; i :Integer; byte1, byte2 :Byte; iLenMin :Integer; begin ms1 := TMemoryStream.Create; ms2 := TMemoryStream.Create; try ms1.LoadFromFile(Trim(edtSelectFile01.Text)); ms2.LoadFromFile(Trim(edtSelectFile02.Text)); if (ms1.Size <> ms2.Size) then begin Memo1.Lines.Add(‘ms1.Size <> ms2.Size : ‘+inttostr(ms1.Size)+‘ , ‘+inttostr(ms2.Size)); Memo1.Lines.Add(‘‘); // Exit; end; iLenMin := ms1.Size; if (iLenMin > ms2.Size) then // 取小值 iLenMin := ms2.Size; Memo1.Lines.Add(‘iLenMin : ‘+inttostr(iLenMin)); Memo1.Lines.Add(‘‘); ms1.Position := 0; ms2.Position := 0; for i:=0 to iLenMin-1 do begin byte1 := 0; byte2 := 0; ms1.Read(byte1, 1); ms2.Read(byte2, 1); if byte1<>byte2 then begin Memo1.Lines.Add(‘!= --> Idx : (‘+inttostr(i)+‘) --> ‘+inttostr(byte1)+‘ , ‘+inttostr(byte2)); end; end; finally ms1.Free; ms2.Free; end; end;
3、
4、
5、
标签:
原文地址:http://www.cnblogs.com/CodeSkill/p/5569130.html