我用delphi写了一个dll
其中有个函数是这样的
function aaa(var pst:pchar):integer;stdcall
var str:string
begin
str='ILOVEYOU'
pst:=Pchar(str);//强制转换
showmessage(pst)//显示真确。为ILOVEYOU
result:=1;
end;
我在vb里调用的时候
declare Function aaa Lib "aaa.dll" (ByVal b As String) As Integerdim b as string;
dim z as integer;
b=space(255);
z=aaa(b)
msgbox b
结果显示的乱maz = aaa(b)
结果返回的值
其中有个函数是这样的
function aaa(var pst:pchar):integer;stdcall
var str:string
begin
str='ILOVEYOU'
pst:=Pchar(str);//强制转换
showmessage(pst)//显示真确。为ILOVEYOU
result:=1;
end;
我在vb里调用的时候
declare Function aaa Lib "aaa.dll" (ByVal b As String) As Integerdim b as string;
dim z as integer;
b=space(255);
z=aaa(b)
msgbox b
结果显示的乱maz = aaa(b)
结果返回的值
declare Function aaa Lib "aaa.dll" (Byref b As String) As Integer 能够真确显示,但byref b as string 和byval b as string 完全是一样的。
其中有个函数是这样的
function aaa(var pst:pchar):integer;stdcall
var str:string
begin
str='ILOVEYOU'
pst:=Pchar(str);//强制转换
showmessage(pst)//显示真确。为ILOVEYOU
result:=1;
end;请问如何调用。
我这样写的 但是返回的值是错误的。
var a:array[0..8] of char;
z:integer;
begin
z:=aaa(a);
showmessage(a);
end;
结果显示的是乱码 而与dll中本身SHOW出来得值不一致。
MAX_SIZE = 传出的最大缓冲区大小
function aaa(const pst:pchar):integer;stdcall
var str:string
begin
str='ILOVEYOU';
StrPLCopy(pst, str, MAX_SIZE-1);
showmessage(pst)//显示真确。为ILOVEYOU
result:=1;
end;