Author: Arthur Young How to patch binary files? Answer: Replaces a string in a file with new string. 1 procedure TForm1.Button1Click(Sender: TObject); 2 var 3 f: file; 4 l: Longint; 5 FileName, oldstring, newstring, s: string; 6 begin 7 oldstring := 'old string'; 8 newstring := 'new string'; 9 FileName := 'c:\YourFileName.xyz'; 10 11 s := oldstring; 12 AssignFile(f, FileName); 13 Reset(f, 1); 14 for l := 0 to FileSize(f) - Length(oldstring) - 1 do 15 begin 16 Application.ProcessMessages; 17 Seek(f, l); 18 BlockRead(f, oldstring[1], Length(oldstring)); 19 if oldstring = s then 20 begin 21 Seek(f, l); 22 BlockWrite(f, newstring[1], Length(newstring)); 23 ShowMessage('String successfully replaced!'); 24 end; 25 Application.ProcessMessages; 26 end; 27 CloseFile(f); 28 end;