| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2775 人关注过本帖
标题:vb 调用 DELPhi Dll 返回空值?怎么回事?
只看楼主 加入收藏
sh_acct_yangxm
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2008-5-14
结帖率:0
收藏
已结贴  问题点数:20 回复次数:3 
vb 调用 DELPhi Dll 返回空值?怎么回事?
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)//这里显示空的
搜索更多相关主题的帖子: false procedure 
2014-08-15 11:46
sh_acct_yangxm
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2008-5-14
收藏
得分:0 
没人帮忙看看?
2014-08-15 13:33
volte
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:69
帖 子:1167
专家分:1316
注 册:2004-12-19
收藏
得分:20 
根据你描述,Delphi的引用参数返回为啥要用out,返回用var引用,不返回没必要用var进行引用;

大家都是朋友,有空就来坐坐!
2014-08-15 15:29
volte
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:69
帖 子:1167
专家分:1316
注 册:2004-12-19
收藏
得分:0 
另外根据描述,这个DLL中的show出来就有问题,说明DLL就有问题,得先把DLL校正;

大家都是朋友,有空就来坐坐!
2014-08-15 15:30
快速回复:vb 调用 DELPhi Dll 返回空值?怎么回事?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011526 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved