我是vb.net的新手,試圖調用Delphi Dll來返回記錄。如果我在結構中放置三個整數,當我嘗試類似下面的代碼時,它會工作「我的方法的類型簽名不是PInvoke兼容的」..任何想法爲什麼我不能添加字節數組或者即使添加布爾值失敗。方法的類型簽名不是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()
的Delphi
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;
在 Passing record as a function result from Delphi DLL to C++
哪一部分引發錯誤? –
什麼是DLL的聲明('getsysinfoF()'的Delphi或C聲明)? –
@Douglas:顯然,試圖編譯''聲明失敗。 –