日期:2014-05-18 浏览次数:21109 次
Double CPUtprt = 0; System.Management.ManagementObjectSearcher mos = new System.Management.ManagementObjectSearcher(@"root\WMI", "Select * From MSAcpi_ThermalZoneTemperature"); foreach (System.Management.ManagementObject mo in mos.Get()) { CPUtprt = Convert.ToDouble(Convert.ToDouble(mo.GetPropertyValue("CurrentTemperature").ToString()) - 2732) / 10; textBox1.Text = ("CPU 溫度 : " + CPUtprt.ToString() + " °C"); }
Public Function GetCPUTemp() As Double Dim i As Integer Dim mCPU As Variant Dim u As Variant Dim s As String Set mCPU = GetObject("WINMGMTS:{impersonationLevel=impersonate}!rootwmi").ExecQuery("Select CurrentTemperature From MSAcpi_ThermalZoneTemperature") For Each u In mCPU s = s & u.CurrentTemperature Next Set mCPU = Nothing GetCPUTemp = (s - 2732) / 10 DoEvents End Function
------解决方案--------------------
在DotFramewoek 中已经封装了System.Management,这里提供的功能已经足以获取系统的信息