Home > database >  For help, pb calls dynamic library written in Delphi, the returned string garbled by parameters
For help, pb calls dynamic library written in Delphi, the returned string garbled by parameters

Time:03-14

Delphi written function:
//define the function called for external StrAddStr
The function StrAddStr (inpustr: PChar; Var OutPutstr: PChar) : integer; Stdcall;
Var
Str1: string;
The begin
Str1:=inpustr;
OutPutstr:=Pchar (str1 + '+' + str1);
Showmessage (OutPutstr);
Result:=0;
end;

Vb call normal:
Public Declare Function StrAddStr Lib "Mydll. DLL" (ByVal str1 As String, ByRef str2 As String) As an Integer

Dim str1, str2 As String

Str1="A1abx"
StrAddStr str1, str2
MsgBox str2

Pb invoke exception:
The 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)
  • Related