struct abc { int a; int b[5] }; struct abc mystruct() { struct abc a1; a1.a=12; for(int i=0;i<5;i++) a1.b[i]=i*i; return a2; }
public struct abc { public int a; public int []b; }; [DllImport("C:\\mydll.dll")] public static extern abc mystruct(); private void button5_Click(object sender, EventArgs e) { abc a2=new bcd () ; a2.b = new int[5]; a2 = mystruct(10); }
"Method's type signature is not PInvoke compatible."
public struct abc { public int a; [System.Runtime.InteropServices.MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] public int[] b; }
[System.Runtime.InteropServices.MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
public fixed int b[5]
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)