static void Main(string[] args)
        {
            OSVersionInfo osvi = new OSVersionInfo();

            osvi.dwOSVersionInfoSize = Marshal.SizeOf(osvi);

            // Obtain the OS version info.
            GetVersionEx(osvi);

            // Display the version information.
            Console.WriteLine("Class size: " + osvi.dwOSVersionInfoSize);
            Console.WriteLine("Major Version: " + osvi.dwMajorVersion);
            Console.WriteLine("Minor Version: " + osvi.dwMinorVersion);
            Console.WriteLine("Build Number: " + osvi.dwBuildNumber);
            Console.WriteLine("Platform Id: " + osvi.dwPlatformId);
            Console.WriteLine("CSD Version: " + osvi.szCSDVersion);
            Console.WriteLine("Platform: " + Environment.OSVersion.Platform);
            Console.WriteLine("Version: " + Environment.OSVersion.Version);

            // Wait to continue.
            Console.WriteLine(Environment.NewLine);
            Console.WriteLine("Main method complete. Press Enter.");
            Console.ReadLine();
        }
 public static extern bool GetVersionEx([In, Out] OSVersionInfo osvi);