在C#中获取操作系统版本/友好名称

我目前正在从事C#项目。我想收集用户统计信息以更好地开发该软件。我正在使用Environment.OSC#的功能,但它仅将操作系统名称显示为类似

我希望能够 到的操作系统实际已知名称, 例如它是否为Windows XP, Windows Vista or Windows

7等。

这可能吗?

回答:

为添加一个参考和using语句System.Management,然后:

public static string GetOSFriendlyName()

{

string result = string.Empty;

ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT Caption FROM Win32_OperatingSystem");

foreach (ManagementObject os in searcher.Get())

{

result = os["Caption"].ToString();

break;

}

return result;

}

以上是 在C#中获取操作系统版本/友好名称 的全部内容, 来源链接: utcz.com/qa/424943.html

回到顶部