求助,pb调用delphi编写的动态库,通过参数返回的字符串乱码
delphi编写的函数:
//定义供外部调用的函数StrAddStr
function StrAddStr(inpustr:PChar ;var OutPutstr:PChar):integer;stdcall;
var
str1:string;
begin
str1:=inpustr;
OutPutstr:=Pchar(str1 + ' + ' + str1);
showmessage(OutPutstr);
result:=0;
end;
vb调用正常:
Public Declare Function StrAddStr Lib "Mydll.dll" (ByVal str1 As String, ByRef str2 As String) As Integer
Dim str1, str2 As String
str1 = "A1abx"
StrAddStr str1, str2
MsgBox str2
pb调用异常:
function int StrAddStr(string str1, ref string str2) library "Mydll.dll"
string ls_1 = "Axc"
string ls_2 = space(20)
StrAddStr(ls_1, ls_2)
messagebox(string(len(ls_2)), ls_2)