zoukankan      html  css  js  c++  java
  • 获得操作系统版本

            /// <summary>
            /// Description : Get Operating System Version
            /// </summary>
            /// <param name="sOsVersionName"></param>
            /// <param name="bRaiseError"></param>
            public static void GetOsVersion(ref  string sOsVersionName, bool bRaiseError = true)
            {
                //TODO PVM This is wrong for Windows XP 64 bit, I have code somewhere for that.  Also not catering for Windows 7
                sOsVersionName = string.Empty;
    
                try
                {
                    OperatingSystem verinfo = Environment.OSVersion;
                    switch (verinfo.Platform)
                    {
                        case PlatformID.Win32NT:
                            switch (verinfo.Version.Major)
                            {
                                case 3:
                                    sOsVersionName = "Windows NT 3.51";
                                    break;
                                case 4:
                                    sOsVersionName = "Windows NT 4.0";
                                    break;
                                case 5:
                                    switch (verinfo.Version.Minor)
                                    {
                                        case 0:
                                            sOsVersionName = "Windows 2000";
                                            break;
                                        case 1:
                                            sOsVersionName = "Windows XP";
                                            break;
                                        case 2:
                                            sOsVersionName = "Windows 2003";
                                            break;
                                    }
                                    break;
                                case 6:
                                    switch (verinfo.Version.Minor)
                                    {
                                        case 0:
                                            // or Windows Server 2008, but system runs on client edition of windows generally, so just show Windows Vista
                                            sOsVersionName = "Windows Vista";
                                            break;
                                        case 1:
                                            // or Windows Server 2008 R2, but system runs on client edition of windows generally, so just show Windows 7
                                            sOsVersionName = "Windows 7";
                                            break;
                                        case 2:
                                            sOsVersionName = "Windows 8";
                                            break;
                                        case 3:
                                            sOsVersionName = "Windows 8.1";
                                            break;
                                        default:
                                            break;
                                    }
                                    break;
                            }
                            break;
    
                        case PlatformID.Win32Windows:
                            switch (verinfo.Version.Major)
                            {
                                case 4:
                                    switch (verinfo.Version.Minor)
                                    {
                                        case 0:
                                            sOsVersionName = "Windows 95";
                                            break;
                                        case 10:
                                            sOsVersionName = "Windows 98";
                                            break;
                                        case 90:
                                            sOsVersionName = "Windows Me";
                                            break;
                                    }
                                    break;
                            }
                            break;
    
                        case PlatformID.Win32S:
                            sOsVersionName = "Windows 32s";
                            break;
                    }
                }
                catch (Exception)
                {
                    if (bRaiseError)
                        throw ();
                }
            }
  • 相关阅读:
    一个大浪Java罢工(一个)安装JDK和环境变量配置
    awk的实施例
    【phpMyAdmin】更改配置文件连接到其他server
    Humming Bird A20 SPI2驱动编译
    2014Esri国际用户大会ArcGIS Online
    POJ 2724 Purifying Machine(最大独立集)
    python学习笔记(五岁以下儿童)深深浅浅的副本复印件,文件和文件夹
    《java系统性能优化》--2.高速缓存
    XAMPP on Mac 组态 Virual Host
    Explicit keyword
  • 原文地址:https://www.cnblogs.com/beyondGodLike/p/3653814.html
Copyright © 2011-2022 走看看