[Mono-list] need some help with PInvoke..

James F. Bellinger zer@neo.rr.com
Wed, 9 Jul 2003 16:40:23 -0400


Why not just use 'ref IntPtr'? No special marshalling would then be
required. :-)

> [StructLayout(LayoutKind.Sequential)] public class HDF {}
> [StructLayout(LayoutKind.Sequential)] public class LPHDF {
>   //[MarshalAs(UnmanagedType.LPStruct)]
>   //public HDF hdf;
>   public int hdf;
> }
>
> public class Hdf {
>   // NEOERR* hdf_init (_HDF **hdf);
>
>   [DllImport("libneo.so", EntryPoint="hdf_init")]
>   [return: MarshalAs(UnmanagedType.LPStruct)]
>   private static extern void hdf_init(
>        [ MarshalAs(UnmanagedType.LPStruct)]
>          LPHDF hdf);
>
> public static int Main(string[] argv) {
>    Console.WriteLine("start test");
>
>     LPHDF lphdf = new LPHDF();
>     hdf_init(lphdf);
>     Console.WriteLine(lphdf.hdf);
>
>
>    return 0;
>  }