300高分求救,将FORM窗体封装到DLL中,但是编译出错。 ( 积分: 300 )

  • 主题发起人 主题发起人 sy.zhuang
  • 开始时间 开始时间
S

sy.zhuang

Unregistered / Unconfirmed
GUEST, unregistred user!
想做个窗体,然后,编译成DLL文件,窗体做好了,可是,DLL编译老是不成功,请高手指点。谢谢。
代码如下:
窗体1代码:
unit getpass;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
Tgetpasswordform = class(TForm)
Edit1: TEdit;
private
{ Private declarations }
public
{ Public declarations }
end;
var
getpasswordform: Tgetpasswordform;

implementation

{$R *.dfm}
function GetPassword(Password: PChar): Boolean;
var
GetPasswordForm: TGetPasswordForm;
begin
Result := False;
GetPasswordForm := TGetPasswordForm.Create(Application);
try
with GetPasswordForm do
if ShowModal = mrOK then
if UpperCase(Edit1.Text) <> StrPas(StrUpper(Password)) then MessageDlg('Invalid Password', mtWarning, [mbOK], 0)
else Result := True;
finally
getPasswordForm.Free;
end;
end;
end.

窗体2代码:
unit setpass;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
Tsetpasswordform = class(TForm)
Edit1: TEdit;
Label1: TLabel;
okbtn: TButton;
cancelbtn: TButton;
procedure FormCreate(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
private
Verified: Boolean;
{ Private declarations }
public
PassWord: PChar;
{ Public declarations }
end;
var
setpasswordform: Tsetpasswordform;
implementation
{$R *.dfm}
procedure Tsetpasswordform.FormCreate(Sender: TObject);
begin
Verified := False;
PassWord := StrAlloc(40);
OKBtn.Enabled := False;
Label1.Caption := 'Please Input PassWord:'
end;
procedure Tsetpasswordform.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if Edit1.text = '' then Exit;
if Key = #13 then
begin
if Verified then
if StrPas(PassWord) = Edit1.text then
begin
OKBtn.Enabled := True;
Edit1.Enabled := False;
OKBtn.SetFocus;
end
else
begin
Verified := False;
MessageDlg('PassWord is InValid.',mtWarning,[mbOK],0);
Edit1.text := '';
PassWord := '';
Label1.Caption := 'Please Input PassWord:';
end
else
begin
Verified := True;
StrPCopy(PassWord,Edit1.text);
Edit1.text := '';
Label1.caption := 'Please Verify PassWord:';
end;
Key := #0;
end;
end;
end.

DLL工程代码:
library passform;

uses
SysUtils,
Classes,
Windows, Messages, Variants, Graphics, Controls, Dialogs, StdCtrls,

GetPass in 'c:/test1/GETPASS.PAS' {PasswordForm},
Setpass in 'c:/test1/SETPASS.PAS' {SetPassWordForm};

{$R *.res}
exports
GetPassword,SetPassWord;
begin
end.


编译DLL是错误提示:
Undeclared identifier 'getpassword'
Undeclared identifier 'setpassword'

望高手复制代码下来,帮我编译一下。
编译环境D7.
急。。。。。。。。
 
unit getpass;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
Tgetpasswordform = class(TForm)
Edit1: TEdit;
private
{ Private declarations }
public
{ Public declarations }
end;
function GetPassword(Password: PChar): Boolean;

implementation

{$R *.dfm}
function GetPassword(Password: PChar): Boolean;
var
GetPasswordForm: TGetPasswordForm;
begin
Result := False;
GetPasswordForm := TGetPasswordForm.Create(Application);
try
with GetPasswordForm do
if ShowModal = mrOK then
if UpperCase(Edit1.Text) <> StrPas(StrUpper(Password)) then MessageDlg('Invalid Password', mtWarning, [mbOK], 0)
else Result := True;
finally
getPasswordForm.Free;
end;
end;
end.
 
早上自己也想出来了,呵呵。不过,还是多谢delphibbs_Lee的江湖救难精神.
结帖啦!
 
对了.最近在写将SPCOMM(COM数据收发的控件)封装到DLL里面去的程序.想知道delphibbs_Lee有没有这方面的经验.可能要用到回调函数.刚开始起步,而且,,时间紧.如果有的话,可否给个DEMO.
需要的话,我再开个贴.
 
后退
顶部