home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1998 April A
/
Pcwk4a98.iso
/
PROGRAM
/
DELPHI16
/
Ypasswrd
/
DLLDOC
/
DLL-INFO.TXT
Wrap
Text File
|
1995-11-28
|
2KB
|
88 lines
Hello,
If you don't want to use my component TYRPasswd, you are still
able to use directly the DLL called PASSWORD.DLL . The way to
proceed is the following :
1) Put the files PASSWORD.DLL and PASSWORD.INI in the directory
of your application (or in the windows/system directory if you
want to protect several applications with the same password).
2) In the main form of your application, do the following :
unit Maindemo;
interface
uses
SysUtils, WinTypes, Messages, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls, FileCtrl, Buttons;
type
...
var
...
{------------------------- HERE ----------------------------}
const
PasswordLoaded : Boolean = False; { Presume nothing! }
var
Login: function(var UserN : String ; var PriorityL : Integer ;
IniFileName,SectionName : String) : WordBool ; { <--- THE BOOLEAN FUNCTION }
UserName : String ;
UserLevel : Integer ;
implementation
{$R *.DFM}
{$IFDEF WINDOWS}
uses WinProcs;
Const SEM_NoOpenFileErrorBox = $8000;
{$ELSE}
uses WinAPI;
{$ENDIF}
var SaveExit: pointer;
DLLHandle: Word;
procedure NewExit; far;
begin
ExitProc := SaveExit;
FreeLibrary(DLLHandle)
end {NewExit};
procedure TDemoForm.FormCreate(Sender: TObject);
begin
{$IFDEF WINDOWS}
SetErrorMode(SEM_NoOpenFileErrorBox);
{$ENDIF}
DLLHandle := LoadLibrary('PASSWORD.DLL');
If DLLHandle >= 32 then { Succes }
Begin
PasswordLoaded := True;
SaveExit := ExitProc;
ExitProc := @NewExit;
@Login := GetProcAddress(DLLHandle,'MOTDEPASSE');
If not Login(UserName,UserLevel,'password.ini','Users')
then Application.Terminate
else Begin
{ initialization }
Color := clGreen ; { Just for the DEMO }
End ;
End else
Begin
MessageDlg('Fichier PASSWORD.DLL introuvable!', mtInformation,[mbOk], 0) ;
Application.Terminate ;
End ;
end;
{------------------------- HERE ----------------------------}
...
end.