delphi的帮助里就有一个例子!

解决方案 »

  1.   

    我的email addr [email protected]
      

  2.   

    这个例子够了吧?
    PAS文件:
    unit dll;interfaceuses
    WinTypes, Classes, Controls, StdCtrls,WinProcs,Graphics,Forms,Buttons,SysUtils;type
      Tpasswordform = class(TForm)
        Edit1: TEdit;
        Button1: TButton;
      private
        { Private declarations }
      public
        { Public declarations }
    end;
    function GetPassword(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('InvalidPassword',mtWarning,[mbOK],0)
    else
    Result:=True;
    finally
    PasswordForm.Free;
    end;
    end;
    end.DPR文件:
    library dllform;uses
      SysUtils,
      Classes,
      dll in 'dll.pas' {passwordform};
      exports getpassword;
    {$R *.RES}begin
    end.