在C#程序中获取当前操作系统的名称可以通过索引WMI的Win32_OperatingSystem对象来获取,参照代码如下:
ManagementObjectSearcher searcher =
new ManagementObjectSearcher("SELECT Caption FROM Win32_OperatingSystem");
String operatingSystem = String.Empty;
foreach (ManagementObject query in searcher0.Get())
{
operatingSystem = query["Caption"].ToString();
break;
}
获取到的名称形如:“Microsoft Windows 10 专业版”
评论区