pb调用delphi的dll文件就是出错,请大侠们指点一下。(100)

L

lin315

Unregistered / Unconfirmed
GUEST, unregistred user!
出现application terminated error:error calling external function read at line 2 in clicked event of object cb_1 of main.dll文件: library Project2;uses SysUtils, Classes; Function read(b1:pchar;d1:integer;a1:pchar):pchar; stdcall ; begin if (b1='1')and (a1='2')then Result:= '正确' else Result:= '错误'; a1:= Result; end ;{$R *.res} exports read;beginend.pb中的函数:public function long read (long b1,long d1,ref string a1) library "project.DLL" alias for "Read"请大侠帮帮看看,指点一下。
 
W

wangdonghai

Unregistered / Unconfirmed
GUEST, unregistred user!
PB里的函数声名错了,delphi的PChar在PB里对应的是什么类型呀,应该不会是long类型吧.虽然没弄过PB,但我猜想应该是这样声名才行:public function string read (long b1,long d1,ref string a1) library "project.DLL" alias for "Read"
 
L

lin315

Unregistered / Unconfirmed
GUEST, unregistred user!
能不能在DLL文件中改呀。
 
L

lin315

Unregistered / Unconfirmed
GUEST, unregistred user!
dll文件我改成这样行不行: library Project2;uses SysUtils, Classes; Function read(b1:pchar;d1:integer;a1:pchar):integer; stdcall ; begin if (b1='1')and (a1='2')then Result:= 1 else Result:= 2 end ;{$R *.res} exports read;beginend.
 
L

lin315

Unregistered / Unconfirmed
GUEST, unregistred user!
救命呀,急急
 
L

lin315

Unregistered / Unconfirmed
GUEST, unregistred user!
脑子搞大了,那位大侠出手一下。
 
L

lin315

Unregistered / Unconfirmed
GUEST, unregistred user!
怎么人没有帮我呀。
 
B

bsense

Unregistered / Unconfirmed
GUEST, unregistred user!
Function read(b1:pchar;d1:integer;a1:pchar):integer; stdcall public function long read (long b1,long d1,ref string a1) library "project.DLL" alias for "Read"上面参数你都知道用refpublic function string read (string b1,string d1,string a1) library "project.DLL" alias for "Read"返回胡是string 而参数似乎不必ref
 
L

lin315

Unregistered / Unconfirmed
GUEST, unregistred user!
能不能改DLL中的函数呀。我总觉得函数声明那里有问题。我用DELPHI程序调用是正确的。
 
顶部