如何使用VB.NET获得硬件的温度?

时间:2014-07-25 19:38:21

标签: vb.net temperature

有没有办法使用VB.NET获取计算机组件(CPU,RAM,GPU)的温度和用途?

感谢。

1 个答案:

答案 0 :(得分:1)

通过谷歌可以轻松找到通过其他WMI探测热传感器的几种资源。 VB .NET is here.

的一个例子

供参考,这是一个示例代码段:

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Try

        Dim searcher As New ManagementObjectSearcher( _

            "root\WMI", "SELECT * FROM MSAcpi_ThermalZoneTemperature")



        For Each queryObj As ManagementObject In searcher.Get()

            Dim temp As Double = CDbl(queryObj("CurrentTemperature"))

            temp = (temp - 2732) / 10.0

            MessageBox.Show(temp.ToString)

        Next

    Catch err As ManagementException

        MessageBox.Show("An error occurred while querying for WMI data: " & err.Message)

    End Try

End Sub

End Class