如何获得"友好" OS版本名称? [英] How to get the "friendly" OS Version Name?
本文介绍了如何获得"友好" OS版本名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要寻找一个优雅的方式来获得操作系统的版本,如:Windows XP专业版服务包1或Windows Server 2008标准版等是否有这样做的一种优雅的方式?我也有兴趣在处理器架构(如x86或x64)。
I am looking for an elegant way to get the OS version like: "Windows XP Professional Service Pack 1" or "Windows Server 2008 Standard Edition" etc. Is there an elegant way of doing that? I am also interested in the processor architecture (like x86 or x64).
欢呼声
推荐答案
您可以使用WMI来获取产品名称(微软的WindowsServer®2008的企业):
You can use WMI to get the product name ("Microsoft® Windows Server® 2008 Enterprise "):
using System.Management;
var name = (from x in new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem").Get().OfType<ManagementObject>()
select x.GetPropertyValue("Caption")).FirstOrDefault();
return name != null ? name.ToString() : "Unknown";
这篇关于如何获得&QUOT;友好&QUOT; OS版本名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文