• C# 获取操作系统版本


    +-----------------------------------------‍------------------------------------------------------------------------------------------+
    |                  | Windows | Windows | Windows | Windows NT | Windows | Windows | Windows | Windows |

    +-----------------------------------------‍------------------------------------------------------------------------------------------+
    |                  |       95     |     98        |      Me     |       4.0          |     2000    |      XP      |     Vista    |      7      |
    +-----------------------------------------------------------------------------------------------------------------------------------+
    | PlatformID |      1         |      1       |        1      |          2       |       2        |      2       |                |                |
    +-----------------------------------------------------------------------------------------------------------------------------------+
    | 主版本号   |      4          |       4       |         4       |         4        |      5        |      5       |       6       |        6      |
    +-----------------------------------------------------------------------------------------------------------------------------------+
    | 副版本号 |       0         |       10      |       90      |        0        |      0         |      1       |        0       |        1      |
    +-----------------------------------------------------------------------------------------------------------------------------------+

    根据上面这个表,从System.Environment中的OSversion取version比较.
    XP 和 2K的Major 都是5, Minor不同,2k对应0,XP对应1.

    System.Environment.OSVersion.Version.Major
    System.Environment.OSVersion.Version.Minor  

    Version ver = System.Environment.OSVersion.Version;
                string strClient = "";
                if (ver.Major == 5 && ver.Minor == 1)
                {
                    strClient = "Win XP";
                }
                else if (ver.Major == 6 && ver.Minor == 0)
                {
                    strClient = "Win Vista";
                }
                else if (ver.Major == 6 && ver.Minor == 1)
                {
                    strClient = "Win 7";
                }
                else if (ver.Major == 5 && ver.Minor == 0)
                {
                    strClient = "Win 2000";
                }
                else
                {
                    strClient = "未知";
                }


    返回导读目录,阅读更多随笔



    分割线,以下为博客签名:

    软件臭虫情未了
    • 编码一分钟
    • 测试十年功


    随笔如有错误或不恰当之处、为希望不误导他人,望大侠们给予批评指正。

  • 相关阅读:
    测试工作中需要用到的一些linux命令
    软件的性能测试到底是测试哪些方面
    软件测试中的安全测试包括哪些方面
    git一不小心上传了大文件,怎么破?
    接口测试校验返回数据格式,JasonSchema使用详解
    selenium定位中需要鼠标悬浮才能显示的按钮
    jenknis参数化构建,windows和shell引用变量
    selenium元素定位之父子节点、胞节点
    selenium元素定位之多个元素中选择其中的一个
    Python实现注册和三次验证登录
  • 原文地址:https://www.cnblogs.com/08shiyan/p/1987607.html
Copyright © 2020-2023  润新知