确定操作系统和处理器类型在C# [英] Determine operating system and processor type in C#

查看:188
本文介绍了确定操作系统和处理器类型在C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要检查什么类型的操作系统我用什么样的处理器。这应该是检查的运行时间。我试图用

I want to check what type of operating system i use and what kind of processor. this should be check on run time. i tried using

System.Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE")

System.OperatingSystem osInfo2 = System.Environment.OSVersion;
Console.WriteLine(osInfo2.ToString());

但它只是VS所运行的环境。
我被告知要使用WMI来检查,但我无法找出如何。 有人可以帮我吗?

but it's just the enviroment that VS is running on.
I was told to use WMI to check it but i can't find out how. can someone help me with that?

推荐答案

是WMI是做这种东西的最佳方式 你可以用它来获取操作系统信息:

Yes WMI is the best way to do this kind of stuff You can use this to retrieve OS informations :

ManagementObjectSearcher objMOS = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM  Win32_OperatingSystem");

这篇关于确定操作系统和处理器类型在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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