,Graphics,Forms,Controls,StdCtrls,ExtCtrls;
type
TForm1=class(TForm)
Edit1:TEdit;
Label1:TLabel;
Button1:TButton;
Bevel1:TBevel;
GroupBox1:TGroupBox;
StatusLbl:TLabel;
procedure Button1Click(Sender:TObject);
end;
TGetPass=function(aa:string):boolean;
var
Form1:TForm1;
getpass:TGetpass;
lhnd:THandle;
aptr:TFarproc;
implementation
uses Dialogs;
{$R*.DFM}
{Import routine from DLL.Takes password to matchand returns boolean.}
{function GetPassword(Password:string):Boolean;far;external′CHKPWORD′;}
{Call password check routine,show status informcaption.}
procedure TForm1.Button1Click(Sender:TObject);
begin
if Edit1.Text=′′then
begin
MessageDlg(′Entersamplepasswordfirst′,mtInformation,[mbOK],0);
Edit1.SetFocus;
end
else
begin
lhnd:=loadlibrary(′Chkpword.dll′);
aptr:=getpro
caddress(lhnd,′GetPassword′);
if TGetpass(aptr)(Edit1.Text) then
StatusLbl.Caption:=′Verifiedpassword′
else
StatusLbl.Caption:=′Invalid password′;
freelibrary(lhnd);
end;
end;
end.
{dllform.pasDLL模块}
unit Dllform;
interface
uses WinTypes,WinProcs,Classes,Graphics,Forms,Controls,Buttons,SysUtils,StdCtrls;
type
TPasswordForm=class(TForm)
Edit1:TEdit;
Label1:TLabel;
BitBtn2:TBitBtn;
BitBtn1:TBitBtn;
end;
function GetPass
word(Password:string):Boolean;export;
implementation
uses Dialogs;
{$R*.DFM}
function GetPassword(Password:string):Boolean;
var
PasswordForm:TPasswordForm;
begin
Result:=False;
PasswordForm:=TPasswordForm.Create(Application);
try
with PasswordForm do
if ShowModal=mrOK then
if UpperCase(Edit1.Text)<>UpperCase(Password) then
MessageDlg(′Invalid Password′,mtWarning,[mbOK],0)
else
Result:=True;
finally
PasswordForm.Free;
end;
end;
end.