1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
   |  
unit login;
interface
uses
  SysUtils, Classes, System.ComponentModel, Borland.Vcl.Controls,
  Borland.Vcl.ExtCtrls, IniFiles, Borland.Vcl.StdCtrls, Borland.Vcl.Forms;
 
type
  Tlogin = class(TForm)
    //déclaration de tout ce qu'il y a sur la form
    Label1: TLabel;
    nomUtilisateur: TComboBox;
    Label2: TLabel;
    Mot_Passe: TEdit;
    Label3: TLabel;
    Button1: TButton;
    Button2: TButton;
    Label4: TLabel;
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Déclarations privées }
  protected
    { Déclarations protégées }
  public
    { Déclarations publiques }
  published
    { Déclarations publiées }
  end;
procedure Register;
implementation
 
procedure Tlogin.FormCreate(Sender: TObject);
begin
    nomUtilisateur.Items.Add('Jean');     //ajout des noms dans la liste
    nomUtilisateur.Items.Add('Francois');
    nomUtilisateur.Items.Add('Pascal');
end;
 
procedure Tlogin.Button1Click(Sender: TObject);
var
  FichierIni          : TIniFile;
  sLecture_FichierIni, sNom_Utilisateur : string;
begin
  FichierIni := TIniFile.create('C:\Mots_Passe.ini');  //fichier mot de passe
  sLecture_FichierIni := FichierIni.ReadString('mot de passe',nomUtilisateur.Text,'Votre mot de passe est erroné. Veuillez le saisir de nouveau');
  if Mot_Passe.Text = sLecture_FichierIni then
    Application.MessageBox('le mot de passe est correct', nil)
  else
    Application.MessageBox('le mot de passe est incorrect', nil);
  FichierIni.Free;
end;
procedure Tlogin.Button2Click(Sender: TObject);
begin
  Application.Free;
end;
end. | 
Partager