从注册表C#检查Windows版本 [英] Check windows version from registry c#

查看:123
本文介绍了从注册表C#检查Windows版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,
我如何可以检查注册表中的Windows版本在C#?

I have a problem, How can I check the windows version from the registry in c#?

(的Windows XP升级到Windows 8.1)

(Windows xp to windows 8.1)

推荐答案

Environment.OSVersion 因为别人说是要走正道。

Environment.OSVersion as others stated is right way to go.

然而,如果有人想通过得到它的注册表,这可以用 -

However, in case someone want to get it through registry, this can be used -

using (Microsoft.Win32.RegistryKey key = 
       Microsoft.Win32.Registry.LocalMachine
               .OpenSubKey(@"SOFTWARE\Microsoft\WindowsNT\CurrentVersion"))
{
    var osVersion = key.GetValue("CurrentVersion");
}



注册表中的版本是 HKLMSOFTWARE\Microsoft \Windows NT\CurrentVersion

另外,从的这里 -

Operating system        Version number
-----------------       --------------
Windows 8                   6.2
Windows Server 2012         6.2
Windows 7                   6.1
Windows Server 2008 R2      6.1
Windows Server 2008         6.0
Windows Vista               6.0
Windows Server 2003 R2      5.2
Windows Server 2003         5.2
Windows XP 64-Bit Edition   5.2
Windows XP                  5.1
Windows 2000                5.0

这篇关于从注册表C#检查Windows版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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