2 using System
.Runtime
.InteropServices
;
4 [StructLayout (LayoutKind
.Sequential
)]
5 public class OSVersionInfo
11 [StructLayout (LayoutKind
.Sequential
)]
12 public struct OSVersionInfo2
21 [DllImport ("libtest", EntryPoint
="MyGetVersionEx")]
22 public static extern int GetVersionEx ([In
, Out
] OSVersionInfo osvi
);
24 [DllImport ("libtest")]
25 public static extern int BugGetVersionEx (int a
, int b
, int c
, int d
, int e
, int f
, int g
, int h
, [In
, Out
] OSVersionInfo osvi
);
27 [DllImport ("libtest", EntryPoint
="MyGetVersionEx")]
28 public static extern int GetVersionEx2 (ref OSVersionInfo2 osvi
);
33 public static int Main()
35 Console
.WriteLine( "\nPassing OSVersionInfo as class" );
37 OSVersionInfo osvi
= new OSVersionInfo();
41 if (LibWrap
.GetVersionEx (osvi
) != 5)
50 Console
.WriteLine( "A: {0}", osvi
.a
);
51 Console
.WriteLine( "B: {0}", osvi
.b
);
53 Console
.WriteLine( "\nPassing OSVersionInfo as struct" );
55 OSVersionInfo2 osvi2
= new OSVersionInfo2();
59 if (LibWrap
.GetVersionEx2 (ref osvi2
) != 5)
68 Console
.WriteLine( "A: {0}", osvi2
.a
);
69 Console
.WriteLine( "B: {0}", osvi2
.b
);
71 Console
.WriteLine ("Testing with extra parameters at the beginning");
73 OSVersionInfo osvi3
= new OSVersionInfo();
77 if (LibWrap
.BugGetVersionEx (10, 10, 10, 10, 20, 20, 20, 20, osvi3
) != 5)
86 Console
.WriteLine( "A: {0}", osvi
.a
);
87 Console
.WriteLine( "B: {0}", osvi
.b
);
89 Console
.WriteLine( "\nPassing OSVersionInfo as struct" );