How do I marshal a pointer to an array of pointers to structures?
        Posted  
        
            by Daniel Stutzbach
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Daniel Stutzbach
        
        
        
        Published on 2010-03-26T21:56:05Z
        Indexed on 
            2010/04/02
            23:43 UTC
        
        
        Read the original article
        Hit count: 274
        
I have a C function with the following signature:
int my_function(int n, struct player **players)
players is a pointer to an array of pointers to struct player objects.  n is the number of pointers in the array.  The function does not modify the array nor the contents of the structures, and it does not retain any pointers after returning.
I tried the following:
[DllImport("mylibary.dll")]
static extern int my_function(int n, 
    [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] 
     player_in []players);
However, that marshals the data as a pointer to an array of structures, not a pointer to an array of pointers to structures.
© Stack Overflow or respective owner