检测的Windows 7在.NET [英] Detect Windows 7 in .net

查看:132
本文介绍了检测的Windows 7在.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

什么code我可以用?

解决方案

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

<$p$p><$c$c>+--------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+ | |窗口|窗口|的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 | +--------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+

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

编辑:更新,更多版本的<一个href="http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/5956c04f-072a-406c-ae6a-cc8b3a207936">this链接

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

修改(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.

这篇关于检测的Windows 7在.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆