如何在C#中获取主板和CPU电压信息?

时间:2011-11-12 10:44:05

标签: c# hardware

就我在互联网上的研究而言,我尝试了一些代码,但它正在发挥作用。它返回'0'值。我的问题是:如何在C#中获得主板和CPU电压信息?

我的代码:

 //http://wutils.com/wmi/
 //create a management scope object
 ManagementScope scope = new ManagementScope("\\\\.\\ROOT\\cimv2");

 //create object query
 ObjectQuery query = new ObjectQuery("SELECT * FROM CIM_VoltageSensor");

 //create object searcher
 ManagementObjectSearcher searcher =
                    new ManagementObjectSearcher(scope, query);

 //get collection of WMI objects
 ManagementObjectCollection queryCollection = searcher.Get();

 //enumerate the collection.
 foreach (ManagementObject m in queryCollection) 
 {
 // access properties of the WMI object
 Console.WriteLine("Accuracy : {0}", m["Accuracy"]);

 }

2 个答案:

答案 0 :(得分:1)

查看OpenHardwareMonitor开源项目。

答案 1 :(得分:0)

您可能会发现this有帮助。这些例子的解释是here

查看frmMain.cs示例。