2
我想弄清楚如何將一個簡單的結構嵌入到另一個傳遞給C#的C DLL的結構中。你如何編制嵌入式結構?剝離爲必需品。如何使用pinvoke將marshall內部的結構傳遞給C DLL
//The C code
typedef struct {
int a;
int b;
} A;
typedef struct {
int c;
A myStruct;
} B;
//The c# code:
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public class A{
int a;
int b;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public class B{
int c;
public IntPtr A;
}