public static void  GetWenDu()
        {
            try
            {
                Double CPUtprt = 0;
                ManagementObjectSearcher mos = new 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;
                    MessageBox.Show("CPU 溫度 : " + CPUtprt.ToString() + " °C");
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc .ToString ());
            }
        }

解决方案 »

  1.   

    上面是一种方法,但需要管理员方式,有不要管理员方式的吗?或者能让管理员方式程序不点击那个WIN7里面的确定,他能够自动运行?我想把温度查看的代码放到一个开机自启动的程序里面。
     
    谢谢大家!
      

  2.   

    我试了一下,有错误try
                {
                    Double CPUtprt = 0;
                    ManagementObjectSearcher mos = new 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;
                        this.lblTemp.Text = CPUtprt.ToString();
                    }            }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
      

  3.   

    补充一下。温度不是固定的。多等会就好了。或者下面放个电热炉
    我用的xp系统。没有任何提示,不用点击任何按钮,就ok