zoukankan      html  css  js  c++  java
  • 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 = "未知";
                }


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



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

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


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

  • 相关阅读:
    并查集-B
    ->的用法
    PTA-1042 字符统计
    PAT 1040有几个PAT
    assembly x86(nasm)修改后的日常
    python接口自动化之操作常用数据库mysql、oracle
    os模块常用方法
    python 多线程编程并不能真正利用多核的CPU
    连接mysql数据库
    python之用yagmail模块发送邮件
  • 原文地址:https://www.cnblogs.com/08shiyan/p/1987607.html
Copyright © 2011-2022 走看看