public static int Main() { Console.WriteLine( "\nPassing OSVersionInfo as class" ); OSVersionInfo osvi = new OSVersionInfo(); osvi.a = 1; osvi.b = 2; if (LibWrap.GetVersionEx (osvi) != 5) return 1; if (osvi.a != 2) return 2; if (osvi.b != 3) return 3; Console.WriteLine( "A: {0}", osvi.a); Console.WriteLine( "B: {0}", osvi.b); Console.WriteLine( "\nPassing OSVersionInfo as struct" ); OSVersionInfo2 osvi2 = new OSVersionInfo2(); osvi2.a = 1; osvi2.b = 2; if (LibWrap.GetVersionEx2 (ref osvi2) != 5) return 4; if (osvi2.a != 2) return 5; if (osvi2.b != 3) return 6; Console.WriteLine( "A: {0}", osvi2.a); Console.WriteLine( "B: {0}", osvi2.b); Console.WriteLine ("Testing with extra parameters at the beginning"); OSVersionInfo osvi3 = new OSVersionInfo(); osvi3.a = 1; osvi3.b = 2; if (LibWrap.BugGetVersionEx (10, 10, 10, 10, 20, 20, 20, 20, osvi3) != 5) return 7; if (osvi3.a != 2) return 8; if (osvi3.b != 3) return 9; Console.WriteLine( "A: {0}", osvi.a); Console.WriteLine( "B: {0}", osvi.b); Console.WriteLine( "\nPassing OSVersionInfo as struct" ); return 0; }
public static void Main() { Console.WriteLine("\nPassing OSVersionInfo as class"); OSVersionInfo osvi = new OSVersionInfo(); osvi.OSVersionInfoSize = Marshal.SizeOf(osvi); LibWrap.GetVersionEx(osvi); Console.WriteLine("Class size: {0}", osvi.OSVersionInfoSize); Console.WriteLine("Major version: {0}", osvi.majorVersion); Console.WriteLine("Minor version: {0}", osvi.minorVersion); Console.WriteLine("Build number: {0}", osvi.buildNumber); Console.WriteLine("Platform ID: {0}", osvi.platformId); Console.WriteLine("Version: {0}", osvi.versionString); Console.WriteLine("\nPassing OSVersionInfo as struct"); OSVersionInfo2 osvi2 = new OSVersionInfo2(); osvi2.OSVersionInfoSize = Marshal.SizeOf(osvi2); LibWrap.GetVersionEx2(ref osvi2); Console.WriteLine("Struct size: {0}", osvi2.OSVersionInfoSize); Console.WriteLine("Major version: {0}", osvi2.majorVersion); Console.WriteLine("Minor version: {0}", osvi2.minorVersion); Console.WriteLine("Build number: {0}", osvi2.buildNumber); Console.WriteLine("Platform ID: {0}", osvi2.platformId); Console.WriteLine("Version: {0}", osvi2.versionString); }
public static void Main() { Console.WriteLine("\nPassing OSVersionInfo as a class"); OSVersionInfo osvi = new OSVersionInfo(); osvi.OSVersionInfoSize = Marshal.SizeOf(osvi); NativeMethods.GetVersionEx(osvi); Console.WriteLine("Class size: {0}", osvi.OSVersionInfoSize); Console.WriteLine("OS Version: {0}.{1}", osvi.MajorVersion, osvi.MinorVersion); Console.WriteLine("\nPassing OSVersionInfo as a struct"); OSVersionInfo2 osvi2 = new OSVersionInfo2(); osvi2.OSVersionInfoSize = Marshal.SizeOf(osvi2); NativeMethods.GetVersionEx2(ref osvi2); Console.WriteLine("Struct size: {0}", osvi2.OSVersionInfoSize); Console.WriteLine("OS Version: {0}.{1}", osvi2.MajorVersion, osvi2.MinorVersion); }
public static extern bool GetVersionEx2(ref OSVersionInfo2 osvi);
internal static extern bool GetVersionEx2(ref OSVersionInfo2 osvi);
public static int Main() { Console.WriteLine("\nPassing OSVersionInfo as class"); OSVersionInfo osvi = new OSVersionInfo(); osvi.a = 1; osvi.b = 2; if (LibWrap.GetVersionEx(osvi) != 5) { return(1); } if (osvi.a != 2) { return(2); } if (osvi.b != 3) { return(3); } Console.WriteLine("A: {0}", osvi.a); Console.WriteLine("B: {0}", osvi.b); Console.WriteLine("\nPassing OSVersionInfo as struct"); OSVersionInfo2 osvi2 = new OSVersionInfo2(); osvi2.a = 1; osvi2.b = 2; if (LibWrap.GetVersionEx2(ref osvi2) != 5) { return(4); } if (osvi2.a != 2) { return(5); } if (osvi2.b != 3) { return(6); } Console.WriteLine("A: {0}", osvi2.a); Console.WriteLine("B: {0}", osvi2.b); Console.WriteLine("Testing with extra parameters at the beginning"); OSVersionInfo osvi3 = new OSVersionInfo(); osvi3.a = 1; osvi3.b = 2; if (LibWrap.BugGetVersionEx(10, 10, 10, 10, 20, 20, 20, 20, osvi3) != 5) { return(7); } if (osvi3.a != 2) { return(8); } if (osvi3.b != 3) { return(9); } Console.WriteLine("A: {0}", osvi.a); Console.WriteLine("B: {0}", osvi.b); Console.WriteLine("\nPassing OSVersionInfo as struct"); return(0); }
public static extern int GetVersionEx2(ref OSVersionInfo2 osvi);