检测的Windows 7在.NETWindows、NET

由网友(阳光快乐小男神)分享简介:我如何检测的Windows 7(版本)在.NET?什么code我可以用?解决方案 System.Environment.OSVersion 有你需要区分大多数Windows操作系统主要版本的信息,但不是全部。它由三部分组成其映射到下面的Windows版本:+--------------------------...

我如何检测的Windows 7(版本)在.NET?

什么code我可以用?

解决方案

System.Environment.OSVersion 有你需要区分大多数Windows操作系统主要版本的信息,但不是全部。它由三部分组成其映射到下面的Windows版本:

+--------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+ | |窗口|窗口|的Windows | Windows NT的|窗口|窗口|窗口|窗口|窗口|窗口|窗口|窗口|窗口|窗口| | | 95 | 98 |我| 4.0 | 2000 | XP | 2003 | Vista的| 2008 | 7 | 2008 R2 | 8 | 8.1 | 10 | +--------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+ | PlatformID | Win32Windows | Win32Windows | Win32Windows | Win32NT | Win32NT | Win32NT | Win32NT | Win32NT | Win32NT | Win32NT | Win32NT | Win32NT | ? | ? | +--------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+ |大| | | | | | | | | | | | | | | |版| 4 | 4 | 4 | 4 | 5 | 5 | 5 | 6 | 6 | 6 | 6 | 6 | 6 | 10 | +--------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+ |小| | | | | | | | | | | | | | | |版| 0 | 10 | 90 | 0 | 0 | 1 | 2 | 0 | 0 | 1 | 1 | 2 | 3 | 0 | +--------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+

有关一个库,让你获得更完整的视图中的确切的视窗,目前的执行环境中运行的版本,检查出的这个库。

编辑:更新,更多版本的this链接

修改(2011/03/15):更改 PlatformID 实际枚举值,而不是int类型,改变了Win 7的一个 1 次编号感谢发表评论指出来(我现在可以用一个Win7机确认),增加了一个链接到库,可以帮助。

部署和分发.NET应用程序的两种方法

修改(2011/03/15):添加了Windows 8.1和10个版本。

重要提示:如果你的可执行程序集清单不明确说明你的EXE程序集是与Windows 8.1和Windows兼容10.0, System.Environment.OSVersion 返回的Windows 8.0版本?!这是6.3和10.0 6.2,代替!!资料来源:这里第一条评论。

How can I detect Windows 7 (versions) in .net?

What code can I use?

解决方案

System.Environment.OSVersion has the information you need for distinguishing most Windows OS major releases, but not all. It consists of three components which map to the following Windows versions:

+--------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+
|           |   Windows    |   Windows    |   Windows    |Windows NT| Windows | Windows | Windows | Windows | Windows | Windows | Windows | Windows |  Windows | Windows |
|           |     95       |      98      |     Me       |    4.0   |  2000   |   XP    |  2003   |  Vista  |  2008   |    7    | 2008 R2 |    8    |   8.1    |   10    |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+
|PlatformID | Win32Windows | Win32Windows | Win32Windows | Win32NT  | Win32NT | Win32NT | Win32NT | Win32NT | Win32NT | Win32NT | Win32NT | Win32NT |  ??      |  ??     |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+
|Major      |              |              |              |          |         |         |         |         |         |         |         |         |          |         |
| version   |      4       |      4       |      4       |    4     |    5    |    5    |    5    |    6    |    6    |    6    |    6    |    6    |     6    |   10    |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+
|Minor      |              |              |              |          |         |         |         |         |         |         |         |         |          |         |
| version   |      0       |     10       |     90       |    0     |    0    |    1    |    2    |    0    |    0    |    1    |    1    |    2    |     3    |    0    |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+

For a library that allows you to get a more complete view of the exact release of Windows that the current execution environment is running in, check out this library.

EDIT: updated with more versions from this link

EDIT (2011/03/15): Changed PlatformID to actual enum values rather than int values, changed Win 7 to a 1 minor number thanks to comment pointing it out (and I can now confirm with a Win7 machine), added a link to a library that can help.

EDIT (2011/03/15): Added Windows 8.1 and 10 versions.

Important note: if your executable assembly manifest doesn't explicitly state that your exe assembly is compatible with Windows 8.1 and Windows 10.0, System.Environment.OSVersion will return Windows 8.0 version ?! which is 6.2, instead of 6.3 and 10.0!! Source: here first comment.

阅读全文

相关推荐

最新文章