注册 登录
编程论坛 Delphi论坛

vb 调用 DELPhi Dll 返回空值?怎么回事?

sh_acct_yangxm 发布于 2014-08-15 11:46, 2775 次点击
Delphi DLL编码:

procedure gncx(var sqlstr,zthstr,ctstr,anstr:pchar;out jg:Pchar);stdcall;
var
   fhjg:widestring;
   sqllj,zth,ctmc,anbh,ls:string;
   th:thandle;
   tf:Tjsjg;
begin
sqllj:=strpas(sqlstr);
zth:=strpas(zthstr);
ctmc:=strpas(ctstr);
anbh:=strpas(anstr);
if wokao(sqllj,zth)=false then begin
   showmessage('该公司无权使用该功能,请确认是否为正版!');
   exit;
end;
fhjg:='';
th:=loadlibrary(pchar('C:\U8add\'+trim(ctmc)+trim(anbh)+'.dll'));
if th>0 then begin
   @tf:=getprocaddress(th,'jsjg');
   try
      if assigned(@tf) then
         fhjg:=tf(pchar(sqllj),pchar(zth));
   finally
      freelibrary(th)
   end;
   end
else begin
   showmessage('调用库文件失败!');
   freelibrary(th);
end;
fhjg:='wokaonima';
move(PChar(fhjg)^,jg^,length(fhjg));
ls:=jg;
showmessage(jg);//这里只能显示“wokao"
end;

VB代码:    Private Declare Unicode Sub gncx Lib "c:\U8add\dcs.dll" (ByRef sqlstr As String, ByRef zthstr As String,
                                                                       ByRef ctstr As String, ByRef anstr As String, ByRef jg As String)

        Call gncx(sql1, zth1, ctmc, gnjmc, jg)
        MsgBox(jg)//这里显示空的
3 回复
#2
sh_acct_yangxm2014-08-15 13:33
没人帮忙看看?
#3
volte2014-08-15 15:29
根据你描述,Delphi的引用参数返回为啥要用out,返回用var引用,不返回没必要用var进行引用;
#4
volte2014-08-15 15:30
另外根据描述,这个DLL中的show出来就有问题,说明DLL就有问题,得先把DLL校正;
1