张
张剑波
Unregistered / Unconfirmed
GUEST, unregistred user!
照书抄的,密码输入框的DLL
DLL原码如下:
library ppass;
uses
sharemem,Upass in 'Upass.pas' {fm_pass};
exports
getpassword;
{$R *.res}
begin
end.
+++++++++++++++++++++++++++++++++
unit Upass;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, StdCtrls;
type
Tfm_pass = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
private
{ Private declarations }
public
{ Public declarations }
end;
var
fm_pass: Tfm_pass;
procedure getpassword(var user:string;var passwd:string);export;
implementation
{$R *.dfm}
procedure getpassword(var user:string;var passwd:string);
begin
fm_pass:=tfm_pass.Create(application);
try
if fm_pass.ShowModal=idok then
begin
user:=fm_pass.edit1.text;
passwd:=fm_pass.edit2.text;
end
else
application.Terminate;
finally
fm_pass.Free;
end;
end;
end.
++++++++++++++++++++++++++++++++++
调用代码如下:
var
Form1: TForm1;
procedure getpassword(var user:string;var passwd:string);far;external'ppass.dll';
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
name,id:string;
begin
getpassword(name,id);
edit1.Text:=name;
edit2.Text:=id;
end;
=============================
调用DLL成功,密码窗体出现,按密码窗体的确认BUTTON,出现错误:
project project1.exe raised exception class
Einvalidpointer with n/message "invalid pointer operation"
DLL原码如下:
library ppass;
uses
sharemem,Upass in 'Upass.pas' {fm_pass};
exports
getpassword;
{$R *.res}
begin
end.
+++++++++++++++++++++++++++++++++
unit Upass;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, StdCtrls;
type
Tfm_pass = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
private
{ Private declarations }
public
{ Public declarations }
end;
var
fm_pass: Tfm_pass;
procedure getpassword(var user:string;var passwd:string);export;
implementation
{$R *.dfm}
procedure getpassword(var user:string;var passwd:string);
begin
fm_pass:=tfm_pass.Create(application);
try
if fm_pass.ShowModal=idok then
begin
user:=fm_pass.edit1.text;
passwd:=fm_pass.edit2.text;
end
else
application.Terminate;
finally
fm_pass.Free;
end;
end;
end.
++++++++++++++++++++++++++++++++++
调用代码如下:
var
Form1: TForm1;
procedure getpassword(var user:string;var passwd:string);far;external'ppass.dll';
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
name,id:string;
begin
getpassword(name,id);
edit1.Text:=name;
edit2.Text:=id;
end;
=============================
调用DLL成功,密码窗体出现,按密码窗体的确认BUTTON,出现错误:
project project1.exe raised exception class
Einvalidpointer with n/message "invalid pointer operation"