P/invoke : Marshaling two-dimensional char array

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kevou
    New Member
    • Oct 2006
    • 2

    #1

    P/invoke : Marshaling two-dimensional char array

    hi,

    I'm currently trying to deal with this struct from C lib using Platform invoke in C#.

    Here is the C struct:

    Code:
    typedef struct
    {
      short myshort;
      char Message[MAX_MESSAGE][MAX_MESS_LEN];
    } mystruct;
    This structure is passed as an argument to many functions of the dll I'm exporting.

    Here is the C# (marshaled) structure in progress:

    Code:
    [ StructLayout( LayoutKind.Sequential, CharSet=CharSet.Ansi )]
    public struct mystruct
    {
      public short myshort;
      [MarshalAs(???)]
      ???
    }
    So basically, could you help me defining the equivalent matrix... I guess i need to use marshaling also... Thanks a lot. I've been searching for days...
  • kevou
    New Member
    • Oct 2006
    • 2

    #2
    [MarshalAs(Unman agedType.ByValA rray, SizeConst=MAX_M ESSAGE * MAX_MESS_LEN)]
    public char[] Message;

    Comment

    • nikishikha
      New Member
      • Dec 2007
      • 1

      #3
      Hi Kevou,

      Any success with it?
      If yes,please send the code....

      Comment

      Working...