Пример #1
0
 public static extern bool GetVersionEx(ref OSVERSIONINFOEX osvi);
Пример #2
0
 public static extern bool GetVersionEx(ref OSVERSIONINFOEX osvi);
Пример #3
0
        /// <summary>
        /// This retrieves the operating system
        /// </summary>
        /// <returns></returns>
        private static OperatingSystem DetermineOperatingSystem()
        {
            int             majorVersion = Environment.OSVersion.Version.Major;
            int             minorVersion = Environment.OSVersion.Version.Minor;
            bool            isServer = false, isBrowserHosted = BrowserInteropHelper.IsBrowserHosted;
            OSVERSIONINFOEX osvi = new OSVERSIONINFOEX();

            // If browser hosted, then do the best we can.  Assume workstation.
            if (!isBrowserHosted)
            {
                osvi.dwOSVersionInfoSize = Marshal.SizeOf(osvi);
                if (NativeMethods.GetVersionEx(ref osvi))
                {
                    isServer = osvi.wProductType != 0x1;
                }
            }

            // Begin OS detection
            OperatingSystem ver = OperatingSystem.Unknown;

            if (majorVersion == 5)
            {
                switch (minorVersion)
                {
                // 5.0 = Windows 200, not allowed for WPF
                case 0:
                    break;

                // 5.1 = Windows XP
                case 1:
                    ver = OperatingSystem.WindowsXP;
                    break;

                // 5.2 = Windows Server 2003, Windows Server 2003R2 or Windows XP 64-bit
                case 2:
                    ver = OperatingSystem.Windows2003;
                    if (!isBrowserHosted)
                    {
                        // Special case 64-bit Windows XP
                        if (!isServer)
                        {
                            ver = OperatingSystem.WindowsXP;
                        }
                        else
                        {
                            if (NativeMethods.GetSystemMetrics(SM_SERVERR2))
                            {
                                ver = OperatingSystem.Windows2003R2;
                            }
                        }
                    }
                    break;
                }
            }
            else if (majorVersion == 6)
            {
                switch (minorVersion)
                {
                // 6.0 = Windows Vista, Windows Server 2008
                case 0:
                    ver = OperatingSystem.WindowsVista;
                    if (!isBrowserHosted && isServer)
                    {
                        ver = OperatingSystem.Windows2008;
                    }
                    break;

                // 6.1 = Windows 7, Windows Server 2008 R2
                case 1:
                    ver = OperatingSystem.Windows7;
                    if (!isBrowserHosted && isServer)
                    {
                        ver = OperatingSystem.Windows2008R2;
                    }
                    break;
                }
            }
            return(ver);
        }
Пример #4
0
        /// <summary>
        /// This retrieves the operating system
        /// </summary>
        /// <returns></returns>
        private static OperatingSystem DetermineOperatingSystem()
        {
            int majorVersion = Environment.OSVersion.Version.Major;
            int minorVersion = Environment.OSVersion.Version.Minor;
            bool isServer = false, isBrowserHosted = BrowserInteropHelper.IsBrowserHosted;
            OSVERSIONINFOEX osvi = new OSVERSIONINFOEX();

            // If browser hosted, then do the best we can.  Assume workstation.
            if (!isBrowserHosted)
            {
                osvi.dwOSVersionInfoSize = Marshal.SizeOf(osvi);
                if (NativeMethods.GetVersionEx(ref osvi))
                    isServer = osvi.wProductType != 0x1;
            }

            // Begin OS detection
            OperatingSystem ver = OperatingSystem.Unknown;
            if (majorVersion == 5)
            {
                switch (minorVersion)
                {
                    // 5.0 = Windows 200, not allowed for WPF
                    case 0:
                        break;
                    // 5.1 = Windows XP
                    case 1:
                        ver = OperatingSystem.WindowsXP;
                        break;
                    // 5.2 = Windows Server 2003, Windows Server 2003R2 or Windows XP 64-bit
                    case 2:
                        ver = OperatingSystem.Windows2003;
                        if (!isBrowserHosted)
                        {
                            // Special case 64-bit Windows XP
                            if (!isServer)
                                ver = OperatingSystem.WindowsXP;
                            else
                            {
                                if (NativeMethods.GetSystemMetrics(SM_SERVERR2))
                                    ver = OperatingSystem.Windows2003R2;
                            }
                        }
                        break;
                }
            }
            else if (majorVersion == 6)
            {
                switch (minorVersion)
                {
                    // 6.0 = Windows Vista, Windows Server 2008
                    case 0:
                        ver = OperatingSystem.WindowsVista;
                        if (!isBrowserHosted && isServer)
                            ver = OperatingSystem.Windows2008;
                        break;
                    // 6.1 = Windows 7, Windows Server 2008 R2
                    case 1:
                        ver = OperatingSystem.Windows7;
                        if (!isBrowserHosted && isServer)
                            ver = OperatingSystem.Windows2008R2;
                        break;
                }
            }
            return ver;
        }