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 ();
                }
            }
  • 相关阅读:
    git warning: LF will be replaced by CRLF in 解决办法
    今天买了个pro,开始ios开发
    基于pyspark的mapreduce实现
    正则表达式中全部符号作用及解释
    CNN
    tensorboard使用及tensorflow各层权重系数输出
    DeepFM tensorflow实现
    FM详解
    sklearn计算auc需要注意的点
    矩阵压缩存储(可用于FM算法中的稀疏矩阵存储)
  • 原文地址:https://www.cnblogs.com/beyondGodLike/p/3653814.html
Copyright © 2011-2022 走看看