Home > Net >  C # and C interoperability problem!
C # and C interoperability problem!

Time:10-12

For the first time to write this kind of project, design to from the c + + provides the methods of a struct array

C + + :
 
Struct IPSWINFO
{
Char * version;
Int index;
Char * url;
Uint64_t totalSize;
};

DLLIMPORT int get_ipsw_files (struct IPSWINFO * * IPSWINFO, int * num);


C # :
Disclaimer:
 
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);

Call:
 
IPSWINFO [] iPSWINFOs;
NativeMethods. Get_ipsw_files (ref iPSWINFOs, ref j);


In a program called, can only get the IPSWINFOs array first, should have had two?? !!!!!
To solve the

CodePudding user response:

///uint64_t
Public long totalSize;

Here try public UInt64 totalSize
  •  Tags:  
  • C#
  • Related