delphi DLL中如何传递string参数?
Function IntToBin(N:Int64;L:Byte):Pchar;stdcall;
var
i: Int64 ;
j: Byte ;
str1:string;
begin
Result:='';str1:='';
i:= N ;
for j:=1 to L do
begin
str1:=str1+Chr(i mod 256 ); i:=i div 256 ;
end ;
result:=Pchar(str1);//在应用程序中调用时返回值出错
end;
原函数是
Function IntToBin(N:Int64;L:Byte):String;
var
i: Int64 ;
j: Byte ;
str1:string;
begin
Result:='';str1:='';
i:= N ;
for j:=1 to L do
begin
str1:=str1+Chr(i mod 256 ); i:=i div 256 ;
end ;
result:=str1;
end;