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.
急。。。。。。。。
代码如下:
窗体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.
急。。。。。。。。