Dadex
Dadex

Reputation: 129

How can I get the hardware's temperatures using VB.NET?

is there any way to get the temperature and the usages of computer components (CPU, RAM, GPU) using VB.NET?

Thanks.

Upvotes: 0

Views: 5804

Answers (1)

Kenneth Aalberg
Kenneth Aalberg

Reputation: 126

There are several resources easily found through google regarding probing thermal sensors through amongst other WMI. One such example for VB .NET is here.

For reference, here's an example snippet:

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

Upvotes: 1

Related Questions