home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 April A / Pcwk4a98.iso / PROGRAM / DELPHI16 / Ypasswrd / DLLDOC / DLL-INFO.TXT
Text File  |  1995-11-28  |  2KB  |  88 lines

  1. Hello,
  2.  
  3. If you don't want to use my component TYRPasswd, you are still
  4. able to use directly the DLL called PASSWORD.DLL . The way to 
  5. proceed is the following :
  6.  
  7. 1) Put the files PASSWORD.DLL and PASSWORD.INI in the directory
  8.    of your application (or in the windows/system directory if you
  9.    want to protect several applications with the same password).
  10.  
  11. 2) In the main form of your application, do the following :
  12.  
  13.    unit Maindemo;
  14.  
  15.    interface
  16.  
  17.    uses
  18.      SysUtils, WinTypes, Messages, Classes, Graphics, Controls,
  19.      Forms, Dialogs, StdCtrls, FileCtrl, Buttons;
  20.  
  21.    type
  22.      ...
  23.  
  24.    var    
  25.      ...
  26.    
  27.    {------------------------- HERE ----------------------------}
  28.    const    
  29.      PasswordLoaded : Boolean = False; { Presume nothing! }
  30.  
  31.    var
  32.      Login: function(var UserN : String ; var PriorityL : Integer ;
  33.                      IniFileName,SectionName : String) : WordBool ; { <--- THE BOOLEAN FUNCTION }
  34.  
  35.      UserName  : String ;
  36.      UserLevel : Integer ;
  37.  
  38.    implementation
  39.  
  40.    {$R *.DFM}
  41.  
  42.    {$IFDEF WINDOWS}
  43.    uses WinProcs;
  44.    Const SEM_NoOpenFileErrorBox = $8000;
  45.    {$ELSE}
  46.    uses WinAPI;
  47.    {$ENDIF}
  48.  
  49.    var SaveExit: pointer;
  50.        DLLHandle: Word;
  51.  
  52.    procedure NewExit; far;
  53.    begin
  54.      ExitProc := SaveExit;
  55.      FreeLibrary(DLLHandle)
  56.    end {NewExit};
  57.  
  58.    procedure TDemoForm.FormCreate(Sender: TObject);
  59.    begin
  60.      {$IFDEF WINDOWS}
  61.      SetErrorMode(SEM_NoOpenFileErrorBox);
  62.      {$ENDIF}
  63.      DLLHandle := LoadLibrary('PASSWORD.DLL');
  64.      If DLLHandle >= 32 then { Succes }
  65.      Begin
  66.        PasswordLoaded := True;
  67.        SaveExit          := ExitProc;
  68.        ExitProc          := @NewExit;
  69.        @Login         := GetProcAddress(DLLHandle,'MOTDEPASSE');
  70.        If not Login(UserName,UserLevel,'password.ini','Users')
  71.        then Application.Terminate
  72.        else Begin
  73.         { initialization }
  74.         Color := clGreen ; { Just for the DEMO }
  75.           End ;    
  76.      End else
  77.      Begin
  78.        MessageDlg('Fichier PASSWORD.DLL introuvable!', mtInformation,[mbOk], 0) ;
  79.        Application.Terminate ;
  80.      End ;
  81.    end;
  82.  
  83.    {------------------------- HERE ----------------------------}
  84.    ...
  85.  
  86.    end.
  87.  
  88.