This tool will pick two separate INI files and combine all keys sections.
The first file overwrites any matching keys on the second file and results become available on a third file.
It will also remember all settings to speed up getting all the rigth paths/files.
Here is the source code (delphi7)
CODE unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons, ExtCtrls, XPMan, Inifiles, Grids, ValEdit;
type TForm1 = class(TForm) OpenDialog1: TOpenDialog; XPManifest1: TXPManifest; LabeledEdit1: TLabeledEdit; LabeledEdit2: TLabeledEdit; LabeledEdit3: TLabeledEdit; Label1: TLabel; Label2: TLabel; Label3: TLabel; BitBtn1: TBitBtn; BitBtn6: TBitBtn; BitBtn2: TBitBtn; BitBtn3: TBitBtn; ValueListEditor1: TValueListEditor; procedure Select_File(Sender: TObject); procedure Create_Output(Sender: TObject); procedure Start_Program(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Create_Output(Sender: TObject); var File1, //File2, OutFile : TMemIniFile;
Memo, SectionList : TStringList;
i,r : Integer;
begin
File1 := TMemIniFile.Create(LabeledEdit1.Text); memo := TStringList.Create; SectionList := TStringList.Create;
// Create a fresh output file using the second file as base memo.LoadFromFile(LabeledEdit2.Text); memo.SaveToFile(LabeledEdit3.Text); memo.Clear;
OutFile := TMemIniFile.Create(LabeledEdit3.Text);
// Get all sections from first file File1.ReadSections(SectionList);
// loop throught every section if SectionList.Count > 0 then for i := 0 to SectionList.Count - 1 do begin memo.Clear; // read all keys inside a section of file1 File1.ReadSection(SectionList[i],memo);
if memo.Count > 0 then for r := 0 to memo.Count - 1 do if Length(memo[r])>0 then begin // write each key from file1 on fileOut OutFile.WriteString(SectionList[i],memo[r],File1.ReadString(SectionList[i],memo[ r],'')); end;
end;//for
OutFile.UpdateFile;
ShowMessage('Completed!');
file1.Free; memo.Free; SectionList.Free; OutFile.Free; end;
The download includes all source files and compiled executable.

|