Dear All,
I am trying to call the data type unsigned char * included in the C DLL and whole structure from C Sharp.
My draft code is below
I encountered
1. to pass unsigned char * from C to C#
2. return structure of Converted from C to C#
3. System.array of C# to IntPtr of C# or unsigned char *
I hope some one will advise me to get it well for my dll and looking forward to hearign from you soon.
Thanks in advance
I am trying to call the data type unsigned char * included in the C DLL and whole structure from C Sharp.
My draft code is below
Code:
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct [B]Converted[/B]
{
public int width;
public int height;
public[B] IntPtr [/B]Buf; // which is [B]unsigned char* in C[/B] and is it correct ?
//[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
};
Converted c = new Converted();
[DllImport("Test.dll", CharSet = CharSet.Auto, EntryPoint="Loading")]
public static extern [B]Converted [/B]Loading([B]ref [/B]IntPtr buf, int size, int type); // shoul I use[B] ref[/B]?
i.data is syste.array
c.Buf = Loading(ref i.data, i.size, type);
1. to pass unsigned char * from C to C#
2. return structure of Converted from C to C#
3. System.array of C# to IntPtr of C# or unsigned char *
I hope some one will advise me to get it well for my dll and looking forward to hearign from you soon.
Thanks in advance
Comment