第一次写这种项目,设计到从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数组的第一项,本来应该有两项的??!!
求解
{
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数组的第一项,本来应该有两项的??!!
求解
public long totalSize; 这里试试 public UInt64 totalSize