dll问题(50分)

  • 主题发起人 主题发起人 broken132
  • 开始时间 开始时间
B

broken132

Unregistered / Unconfirmed
GUEST, unregistred user!
我在做好dll文件之后
在编译时总是出现说没有定义fnvini
其中fnvini是我dll文件中引出历程的定义
是在主程序中吊用的
如何让我的dll文件与主程序项链,并能编译通过
 
贴出代码
 
DLL 文件的 uses 中是否有主程序单元?
 
library baojian1;

uses
sharemem,
SysUtils,
Classes,
baojian in 'baojian.pas' {baojianfrm},
xinxiluru in 'xinxiluru.pas' {xinxilurufrm},
xinxifind in 'xinxifind.pas' {xinxifindfrm},
findtiaojian in 'findtiaojian.pas' {findtiaojianfrm},
tizhongxianzhifind in 'tizhongxianzhifind.pas' {tizhongxianzhifindfrm},
ziliaofind in 'ziliaofind.pas' {ziliaofindfrm},
fengmiannew in 'fengmiannew.pas' {fengmiannewfrm},
denglufrm in 'denglufrm.pas' {denglfrm},
yhbweihu in 'yhbweihu.pas' {yhbweihufrm},
newuserinf in 'newuserinf.pas' {newuserinffrm},
xiugaiuserinf in 'xiugaiuserinf.pas' {xiugaiuserinffrm},
dizhibweihu in 'dizhibweihu.pas' {dizhibweihufrm},
dizhiadd in 'dizhiadd.pas' {dizhiaddfrm},
dizhixiugai in 'dizhixiugai.pas' {dizhixiugaifrm},
jiatingdangan in 'jiatingdangan.pas' {jiatingdjfrm},
jiatingxxcx in 'jiatingxxcx.pas' {jiatingxxcxfrm},
jtcxtj in 'jtcxtj.pas' {jtcxtjfrm},
jbcx in 'jbcx.pas' {jbcxfrm},
srjb in 'srjb.pas' {srjbfrm},
jbtj in 'jbtj.pas' {jbtjfrm},
jbybt in 'jbybt.pas' {jbybtfrm};

{$E dll}


{$R *.RES}
exports
fbjxtini;

begin

end.



主程序
unit sqxt;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, Menus, OleCtrls, jpeg,
ExtCtrls;

type
tini=function(user:string;yyid:string):boolean;
Tsqxtfrm = class(TForm)
myPopupMenu: TPopupMenu;
N5: TMenuItem;
N6: TMenuItem;
N7: TMenuItem;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
N8: TMenuItem;
N9: TMenuItem;
N10: TMenuItem;
N11: TMenuItem;
N12: TMenuItem;
N13: TMenuItem;
GroupBox1: TGroupBox;
BitBtn1: TBitBtn;
Label1: TLabel;
Label2: TLabel;
Image1: TImage;
N14: TMenuItem;
N15: TMenuItem;
N16: TMenuItem;
N17: TMenuItem;
N18: TMenuItem;
N19: TMenuItem;
OpenDialog1: TOpenDialog;
procedure BitBtn1Click(Sender: TObject);
procedure N4Click(Sender: TObject);
procedure N5Click(Sender: TObject);
procedure N6Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure N7Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure N3Click(Sender: TObject);
procedure N15Click(Sender: TObject);
procedure N18Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
sqxtfrm: Tsqxtfrm;

implementation
uses denglu,gyxt,shellapi;
//function fetbjini(user:string;yyid:string):boolean;external 'etbj1.dll'
//function fbjxtini(user:string;yyid:string):boolean;external 'baojian1.dll';
//function fetmyint(user:string;yyid:string):boolean;external 'etmydll.dll';
//function fnbjini(user:string;yyid:string):boolean;external 'fnbjdll.dll';
//function fyfbjini(user:string;yyid:string):boolean;external 'yuenfu1.dll';
{$R *.DFM}

procedure Tsqxtfrm.BitBtn1Click(Sender: TObject);
begin
MyPopUpMenu.Popup(sqxtfrm.Left ,575);

// if caidanfrm =nil then caidanfrm:=tcaidanfrm.Create(application);
// caidanfrm.Show
end;

procedure Tsqxtfrm.N4Click(Sender: TObject);
begin
application.Terminate
end;

procedure Tsqxtfrm.N5Click(Sender: TObject);
var
order :boolean;
user:string;
yyid:string;
pfunc:tfarproc;
moudle:thandle;
begin
moudle:=loadlibrary('etbj1.dll');
if moudle >32 then
begin
user:=denglu.yhm;
yyid:=denglu.yymc;
pfunc:=getprocaddress(moudle,'fetbjini');
order :=tini(pfunc)(user,yyid);
if order =false then
showmessage('程序加载错误!');
end;
freelibrary(moudle)
end;

procedure Tsqxtfrm.N6Click(Sender: TObject);
var
order :boolean;
user:string;
yyid:string;
pfunc:tfarproc;
moudle:thandle;
begin
moudle:=loadlibrary('baojian1.dll');
if moudle >32 then
begin
user:=denglu.yhm;
yyid:=denglu.yymc;
pfunc:=getprocaddress(moudle,'fbjxtini');
order :=tini(pfunc)(user,yyid);
if order =false then
showmessage('程序加载错误!');
end;
freelibrary(moudle)
end;
end.
 
该dll文件只是主程序所调用的一个模块而已
所以他们不属于同意个工程文件
 
老兄,到底是DLL工程编译出错,还是主程序编译出错?
如果是DLL,那你的fnvini在哪个单元?library文件中有没有use了这个单元
 
fnvini只是一个供其他单元调用该dll的例城
 
建议你改动如下:
pfunc:=getprocaddress(moudle,'fbjxtini');//注意此处你不一定能得到函数入口指针
if pfunc <> nil then
order :=tini(pfunc)(user,yyid)
else
RaiseLastWin32Error

 
后退
顶部