示例#1
0
        public static string GetOSName()
        {
            _OSVERSIONINFOEX osVersionInfo = new _OSVERSIONINFOEX();

            osVersionInfo.dwOSVersionInfoSize = 156;

            if (GetVersionEx(ref osVersionInfo))
            {
                switch (osVersionInfo.dwMajorVersion)
                {
                case 5:
                    switch (osVersionInfo.dwMinorVersion)
                    {
                    case 0:
                        return("Microsoft Windows 2000");

                    case 1:
                        return("Microsoft Windows XP");

                    case 2:
                        if ((osVersionInfo.wSuiteMask & 0x00008000) != 0)
                        {
                            return("Microsoft Windows Home Server");
                        }
                        if (osVersionInfo.wProductType == 1 && CheckOSBitness.Is64BitOperatingSystem())
                        {
                            return("Microsoft Windows XP");
                        }
                        if (GetSystemMetrics(89) == 0)
                        {
                            return("Microsoft Windows Server 2003");
                        }
                        else
                        {
                            return("Microsoft Windows Server 2003 R2");
                        }
                    }
                    break;

                case 6:
                    switch (osVersionInfo.dwMinorVersion)
                    {
                    case 0:
                        if (osVersionInfo.wProductType == 1)
                        {
                            return("Microsoft Windows Vista");
                        }
                        else
                        {
                            return("Microsoft Windows Server 2008");
                        }

                    case 1:
                        if (osVersionInfo.wProductType == 1)
                        {
                            return("Microsoft Windows 7");
                        }
                        else
                        {
                            return("Microsoft Windows Server 2008 R2");
                        }

                    default:
                        return("The later version of Microsoft Windows Vista");
                    }
                    break;
                }
            }
            return(null);
        }
示例#2
0
 public static extern bool GetVersionEx(ref _OSVERSIONINFOEX osVersionInfo);