System.Environment.OSVersion
具有区分大多数Windows OS主要版本(而非全部)所需的信息。它由三个组件组成,这些组件映射到以下Windows版本:
+------------------------------------------------------------------------------+
| | PlatformID | Major version | Minor version |
+------------------------------------------------------------------------------+
| Windows 95 | Win32Windows | 4 | 0 |
| Windows 98 | Win32Windows | 4 | 10 |
| Windows Me | Win32Windows | 4 | 90 |
| Windows NT 4.0 | Win32NT | 4 | 0 |
| Windows 2000 | Win32NT | 5 | 0 |
| Windows XP | Win32NT | 5 | 1 |
| Windows 2003 | Win32NT | 5 | 2 |
| Windows Vista | Win32NT | 6 | 0 |
| Windows 2008 | Win32NT | 6 | 0 |
| Windows 7 | Win32NT | 6 | 1 |
| Windows 2008 R2 | Win32NT | 6 | 1 |
| Windows 8 | Win32NT | 6 | 2 |
| Windows 8.1 | Win32NT | 6 | 3 |
+------------------------------------------------------------------------------+
| Windows 10 | Win32NT | 10 | 0 |
+------------------------------------------------------------------------------+
要使您可以更完整地了解正在运行当前执行环境的Windows 确切 版本的库,请签出该库。
:如果您的可执行程序集清单未明确声明您的exe程序集与Windows 8.1和Windows 10.0兼容,System.Environment.OSVersion
则将返回Windows 8版本,即6.2,而不是6.3和10.0!资料来源:这里。