How to get the quot;friendlyquot; OS Version Name?(如何获得“友好?操作系统版本名称?)
问题描述
我正在寻找一种优雅的方式来获取操作系统版本,例如:Windows XP Professional Service Pack 1"或Windows Server 2008 Standard Edition"等.
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?
我也对处理器架构(如 x86 或 x64)感兴趣.
I am also interested in the processor architecture (like x86 or x64).
推荐答案
您可以使用WMI获取产品名称(Microsoft® Windows Server® 2008 Enterprise"):
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 Caption FROM Win32_OperatingSystem").Get().Cast<ManagementObject>()
select x.GetPropertyValue("Caption")).FirstOrDefault();
return name != null ? name.ToString() : "Unknown";
这篇关于如何获得“友好"?操作系统版本名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何获得“友好"?操作系统版本名称?
基础教程推荐
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- WPF 模态进度窗口 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
