第一次寫這種專案,設計到從C++提供的方法中拿到一個結構體陣列
C++:
struct IPSWINFO
{
char* version;
int index;
char* url;
uint64_t totalSize;
};
DLLIMPORT int get_ipsw_files(struct IPSWINFO** ipswInfo, int* num);
C#:
宣告:
public struct IPSWINFO {
/// char*
[MarshalAs(UnmanagedType.LPStr)]
public string version;
/// int
public int index;
/// char*
[MarshalAs(UnmanagedType.LPStr)]
public string url;
/// uint64_t
public long totalSize;
}
[DllImport("idevicerestore.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int get_ipsw_files(ref IPSWINFO[] ps, ref int num);
呼叫:
IPSWINFO[] iPSWINFOs;
NativeMethods.get_ipsw_files(ref iPSWINFOs, ref j);
在程式呼叫時,只能拿到那個IPSWINFOs陣列的第一項,本來應該有兩項的??!!
求解
uj5u.com熱心網友回復:
/// uint64_tpublic long totalSize;
這里試試 public UInt64 totalSize
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/133797.html
標籤:C#
