unit Unit4;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, inifiles, XPMan, DKLang;

type
  TForm4 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Button1: TButton;
    Label1: TLabel;
    Label2: TLabel;
    Button2: TButton;
    OpenDialog1: TOpenDialog;
    XPManifest1: TXPManifest;
    Button3: TButton;
    Button4: TButton;
    DKLanguageController1: TDKLanguageController;
    procedure Button4Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Déclarations privées }
  public
    { Déclarations publiques }
  end;

var
  Form4: TForm4;

implementation

uses Main;

{$R *.dfm}

{============================================================================}
{ fonction qui renvoie la sous chaine de caractère situè à droite de la sous }
{ chaine substr                                                              }
{ ex: si substr = '\' et S= 'truc\tr\essai.exe' gauche renvoie truc          }
{============================================================================}

function droite(substr: string; s: string): string;
begin
  if pos(substr,s)=0 then result:='' else
    result:=copy(s, pos(substr, s)+length(substr), length(s)-pos(substr, s)+length(substr));
end;


procedure TForm4.Button2Click(Sender: TObject);
begin
if opendialog1.Execute then
Edit2.Text:= OpenDialog1.FileName;
end;

procedure TForm4.Button1Click(Sender: TObject);
var ProfIni: TIniFile;
    Temp_Nom, Nom_profil: String;
    Temp_prof: tstringlist;
    Mark, i : integer;
begin
ProfIni:=TInifile.Create(ExtractFilePath(Application.ExeName)+'profils.ini');
if Form1.button37.visible=true then
Nom_Profil:=Form1.ComboBox2.Text
else Nom_Profil:=Form1.Edit1.Text;
Temp_prof:= Tstringlist.create;
if Edit1.Text<>'' then Temp_Nom:=Edit1.Text
else Temp_Nom:=Edit2.Text;
ProfIni.ReadSection(Nom_Profil, Temp_prof);
Mark:=1;
for i:=0 to Temp_Prof.count-1 do
if Temp_Prof.Strings[Temp_Prof.Count-1]='Lien'+Inttostr(i) then
Mark:=i+1;
ProfIni.WriteString(Nom_Profil, 'Lien'+inttostr(Mark), Edit2.Text+';'+Temp_Nom);
Form1.ListBox1.Items.add(Temp_Nom);
Edit1.Clear;
Edit2.Clear;
end;

procedure TForm4.Button3Click(Sender: TObject);
var ProfIni: TIniFile;
    Nom_profil, Temp_Nom: String;
    Temp_prof: tstringlist;
    Mark, i: integer;
begin
ProfIni:=TInifile.Create(ExtractFilePath(Application.ExeName)+'profils.ini');
if Form1.button37.visible=true then
Nom_Profil:=Form1.ComboBox2.Text
else Nom_Profil:=Form1.Edit1.Text;
Temp_prof:= Tstringlist.create;
if Edit1.Text<>'' then Temp_Nom:=Edit1.Text
else Temp_Nom:=Edit2.Text;
ProfIni.ReadSection(Nom_Profil, Temp_prof);
Mark:=1;
for i:=0 to Temp_Prof.count-1 do
if Temp_Prof.Strings[Temp_Prof.Count-1]='Lien'+Inttostr(i) then
Mark:=i+1;
ProfIni.WriteString(Nom_Profil, 'Lien'+inttostr(Mark), Edit2.Text+';'+Temp_Nom);
Form1.ListBox1.Items.add(Temp_Nom);
Edit1.Clear;
Edit2.Clear;
Form4.Hide;
end;

procedure TForm4.Button4Click(Sender: TObject);
begin
Form4.Hide;
end;

end.
