请教用DELPHI该如何创建和调用DLL工程文件?
我的操作步骤是这一样的:
1。 在DELPHI中新建了一个dll,保存为ff.DPR,代码如下
library ff;
uses
SysUtils,
Classes,
test in 'test.pas';{此窗体已建好}
{$R *.RES}
function cre():boolean;far;export;
var
ld:tform1;
begin
ld:=form1.Create(nil);
ld.show;
result:=true;
end;
exports cre;
begin
end.
2。编译生成ff.dll,保存在e:\temp\
3。另建一工程fd.dpr 来调用ff.dll 代码如下
unit test;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
function cre():boolean;far;external'e:\temp\ff';
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
if cre() then
showmessage('good');
end;
end.
4.编译fd.dpr出错信息为:
access violation at address 00461655 in module 'ff.dll'.read of
address ffffffff.
请众大侠赐教,最好附上源代码,谢谢!