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)//这里显示空的