home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 April A / Pcwk4a98.iso / PROGRAM / DELPHI16 / Ypasswrd / YRMAIN.PAS < prev    next >
Pascal/Delphi Source File  |  1995-11-28  |  3KB  |  103 lines

  1. unit Yrmain;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, Buttons, StdCtrls, Spin, YRPasswd ;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Button1: TButton;
  12.     BitBtn1: TBitBtn;
  13.     Label1: TLabel;
  14.     Label2: TLabel;
  15.     Edit1: TEdit;
  16.     Edit2: TEdit;
  17.     LoginLabel: TLabel;
  18.     Label3: TLabel;
  19.     Label4: TLabel;
  20.     Edit3: TEdit;
  21.     Edit4: TEdit;
  22.     Mypswd: TYRPasswd;
  23.     procedure BitBtn1Click(Sender: TObject);
  24.     procedure Button1Click(Sender: TObject);
  25.     procedure FormCreate(Sender: TObject);
  26.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  27.   private
  28.     { Private declarations }
  29.   public
  30.     { Public declarations }
  31.   end;
  32.  
  33. var
  34.   Form1: TForm1;
  35.  
  36. implementation
  37.  
  38. {$R *.DFM}
  39.  
  40. procedure TForm1.Button1Click(Sender: TObject);
  41. begin
  42.   Hide ;
  43.   If not Mypswd.GetPassword    then
  44.   Begin
  45.       If not Mypswd.ExistDll
  46.       then    MessageDlg('File PASSWORD.DLL is missing' + #13#10 + #13#10 +
  47.                                    'You are not authorized to use this program !', mtInformation,[mbOk], 0)
  48.       else    MessageDlg('BAD PASSWORD....', mtInformation,[mbOk], 0);
  49.     Form1.Color := clRed  ;
  50.     LoginLabel.Visible := False ;
  51.   End else
  52.   Begin
  53.       MessageDlg('GOOD PASSWORD....', mtInformation,[mbOk], 0);
  54.     Form1.Color                 := clGreen ;
  55.     LoginLabel.Visible     := True ;
  56.   End ;
  57.   Show ;
  58.   LoginLabel.Visible     := Mypswd.OkLogin ;
  59.   Edit1.Text                     := Mypswd.UserName ;
  60.   Edit2.Text                    := IntToStr(Mypswd.UserLevel) ;
  61.   Edit3.Text                     := Mypswd.IniName ;
  62.   Edit4.Text                     := Mypswd.SectionName ;
  63. end;
  64.  
  65. procedure TForm1.FormCreate(Sender: TObject);
  66. begin
  67.   If not Mypswd.GetPassword    then
  68.   Begin
  69.       If not Mypswd.ExistDll
  70.          then    MessageDlg('File PASSWORD.DLL is missing' + #13#10 + #13#10 +
  71.                                     'You are not authorized to use this program !', mtInformation,[mbOk], 0)
  72.          else    MessageDlg('BAD PASSWORD....', mtInformation,[mbOk], 0);
  73.     Application.Terminate ;
  74.   End else
  75.   Begin
  76.       MessageDlg('GOOD PASSWORD....', mtInformation,[mbOk], 0);
  77.       Form1.Color := clGreen ;
  78.       Edit1.Text     := Mypswd.UserName ;
  79.       Edit2.Text    := IntToStr(Mypswd.UserLevel) ;
  80.       Edit3.Text     := Mypswd.IniName ;
  81.       Edit4.Text     := Mypswd.SectionName ;
  82.   End ;
  83. end;
  84.  
  85. procedure TForm1.BitBtn1Click(Sender: TObject);
  86. begin
  87.     Close ;
  88. end;
  89.  
  90. procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
  91. begin
  92.   if MessageDlg('Close application ?', mtConfirmation,
  93.     [mbYes, mbNo], 0) = mrYes then
  94.   begin
  95.     Action := caFree ;
  96.     Mypswd.FreeDllPassword ;
  97.   end
  98.   else
  99.     Action := caNone;
  100. end;
  101.  
  102. end.
  103.