zoukankan      html  css  js  c++  java
  • C#判断操作系统类型汇总

    Windows操作系统的版本号一览

    操作系统

    PlatformID

    主版本号

    副版本号

    Windows95

    1

    4

    0

    Windows98

    1

    4

    10

    WindowsMe

    1

    4

    90

    WindowsNT3.5

    2

    3

    0

    WindowsNT4.0

    2

    4

    0

    Windows2000

    2

    5

    0

    WindowsXP

    2

    5

    1

    Windows2003

    2

    5

    2

    WindowsVista

    2

    6

    0

    Windows7

    2

    6

    1

    Windows8

     

     

     

    获取操作系统信息的相关类或属性

    //获取系统信息
    System.OperatingSystem osInfo = System.Environment.OSVersion;

    //获取操作系统ID
    System.PlatformID platformID = osInfo.Platform;

    //获取主版本号
    int versionMajor = osInfo.Version.Major;

    //获取副版本号
    int versionMinor = osInfo.Version.Minor;

    System.PlatformID枚举值及其含义

    Win32S 操作系统为 Win32s(Win32 子集)类型。
    Win32s 是运行于 Windows 16 位版本上的层,它提供对 32 位应用程序的访问。
    Win32Windows 操作系统为 Windows 95 或较新的版本。
    Win32NT 操作系统为 Windows NT 或较新的版本。
    WinCE 操作系统为 Windows CE。
    Unix 操作系统为 Unix。
    Xbox 开发平台为 Xbox 360。

    示例

    //C#判断操作系统是否为Windows98
    public static bool IsWindows98
    {
    get
    {
    return (Environment.OSVersion.Platform == PlatformID.Win32Windows) && (Environment.OSVersion.Version.Minor == 10) && (Environment.OSVersion.Version.Revision.ToString() != "2222A");
    }
    }

    //C#判断操作系统是否为Windows98第二版
    public static bool IsWindows98Second
    {
    get
    {
    return (Environment.OSVersion.Platform == PlatformID.Win32Windows) && (Environment.OSVersion.Version.Minor == 10) && (Environment.OSVersion.Version.Revision.ToString() == "2222A");
    }
    }

    //C#判断操作系统是否为Windows2000
    public static bool IsWindows2000
    {
    get
    {
    return (Environment.OSVersion.Platform == PlatformID.Win32NT) && (Environment.OSVersion.Version.Major == 5) && (Environment.OSVersion.Version.Minor == 0);
    }
    }

    //C#判断操作系统是否为WindowsXP
    public static bool IsWindowsXP {
    get {
    return (Environment.OSVersion.Platform == PlatformID.Win32NT) && (Environment.OSVersion.Version.Major == 5) && (Environment.OSVersion.Version.Minor == 1);
    }
    }

    //C#判断操作系统是否为Windows2003
    public static bool IsWindows2003
    {
    get
    {
    return (Environment.OSVersion.Platform == PlatformID.Win32NT) && (Environment.OSVersion.Version.Major == 5) && (Environment.OSVersion.Version.Minor == 2);
    }
    }

    //C#判断操作系统是否为WindowsVista
    public static bool IsWindowsVista
    {
    get
    {
    return (Environment.OSVersion.Platform == PlatformID.Win32NT) && (Environment.OSVersion.Version.Major == 6) && (Environment.OSVersion.Version.Minor == 0);
    }
    }

    //C#判断操作系统是否为Windows7
    public static bool IsWindows7
    {
    get
    {
    return (Environment.OSVersion.Platform == PlatformID.Win32NT) && (Environment.OSVersion.Version.Major == 6) && (Environment.OSVersion.Version.Minor == 1);
    }
    }

    //C#判断操作系统是否为Unix
    public static bool IsUnix
    {
    get
    {
    return Environment.OSVersion.Platform == PlatformID.Unix;
    }
    }

     

  • 相关阅读:
    在一个字符串中找到第一个只出现一次的字符
    查找最小的k个数
    动规:最大上升子序列
    平衡二叉树
    【笔记】php和mysql结合 搞了一个表出来
    设计模式心得(既设计模式篇终章):描述设计模式时的通用公式
    分享系列 之 linux IO原理与几种零拷贝机制的实现
    近期分享:BIO 与 NIO 的实质区别到底是什么?
    源码阅读笔记 之 ThreadLocal —— 不复杂,却有点绕的一个 per thread API
    小脑袋瓜充满了问号:为什么AMQP可以叫做 Advanced?JMS就要low一等吗?
  • 原文地址:https://www.cnblogs.com/1175429393wljblog/p/5408894.html
Copyright © 2011-2022 走看看