home *** CD-ROM | disk | FTP | other *** search
/ PC Format Collection 48 / SENT14D.ISO / tech / delphi / disk12 / calldll.pak / MAIN.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1995-08-24  |  1.1 KB  |  50 lines

  1. { Password demonstration program. Calls a routine in CHKPWORD.DLL to
  2.   prompt the user for a password. CHKPWORD contains a form in a DLL. }
  3.  
  4. unit Main;
  5.  
  6. interface
  7.  
  8. uses WinTypes, WinProcs, Classes, Graphics, Forms, Controls, StdCtrls,
  9.   ExtCtrls;
  10.  
  11. type
  12.   TForm1 = class(TForm)
  13.     Edit1: TEdit;
  14.     Label1: TLabel;
  15.     Button1: TButton;
  16.     Bevel1: TBevel;
  17.     GroupBox1: TGroupBox;
  18.     StatusLbl: TLabel;
  19.     procedure Button1Click(Sender: TObject);
  20.   end;
  21.  
  22. var
  23.   Form1: TForm1;
  24.  
  25. implementation
  26.  
  27. uses Dialogs;
  28.  
  29. {$R *.DFM}
  30.  
  31. { Import routine from DLL. Takes password to match and returns boolean. }
  32. function GetPassword(Password: string): Boolean;
  33.   far; external 'CHKPWORD';
  34.  
  35. { Call password check routine, show status in form caption. }
  36. procedure TForm1.Button1Click(Sender: TObject);
  37. begin
  38.   if Edit1.Text = '' then
  39.   begin
  40.     MessageDlg('Enter sample password first', mtInformation, [mbOK], 0);
  41.     Edit1.SetFocus;
  42.   end
  43.   else
  44.     if GetPassword(Edit1.Text) then
  45.       StatusLbl.Caption := 'Verified password'
  46.     else StatusLbl.Caption := 'Invalid password';
  47. end;
  48.  
  49. end.
  50.