我是 vb.net 的新手,并试图调用返回记录的 Delphi Dll。如果我在 struct 中放入三个整数,当我尝试类似下面的代码时它会起作用,我会得到“方法的类型签名与 PInvoke 不兼容”。关于为什么我不能添加字节数组或者即使我添加布尔值它也会失败的任何想法。
Public Structure SysInfo
Public iPrtRes As Integer
Public iMaxRips As Integer
Public iUnits As Integer
Public str As Byte()
End Structure
<DllImport("C:\project2.DLL", CallingConvention:=CallingConvention.Cdecl)>
Public Function getsysinfoF() As SysInfo
End Function
Dim theSysInfoRec As SysInfo
ReDim theSysInfoRec.str(255)
theSysInfoRec = getsysinfoF()
德尔福
type
SysInfo = record
iPrtRes: Integer;
iMaxRips: Integer;
iUnits: Integer;
str: array[0..255] of Byte;
end;
function getsysinfoF() : SysInfo; cDecl
begin
result.iPrtRes := 400;
result.iMaxRips := 300;
result.iUnits := 200;
result.str[0] := $ff;
end;