CPU Temperature

  • Thread starter Thread starter anthony
  • Start date Start date
A

anthony

One the computer I am programmig I could see the CPU temperature in the
BIOS, is there a system DLL in VB.NET that I can call to display the
temperature in my software?

Thanks!
 
Anthony,

You can use WMI if your hardware is compliant. Use the wbemtest.exe
utility to confirm whether or not you can even retrieve the
temperature. There are two ways I know of to retrieve the temperature
information.

1) Using wbemtest.exe connect to the namespace "root\cimv2" (without
quotes). Click the Query button and enter "select * from
Win32_TemperatureProbe". Double click on any result you get back and
look for the CurrentReading property in the properties section. The
value you see there should be the temperature. If it just shows
"<null>" then this option will not work.

2) Using wbemtest.ext connect to the namespace "root\WMI". Enter the
query "select * from MSAcpi_ThermalZoneTemperature". Double click on
any result you get back and look for the CurrentTemperature property.
The value is in tenths of degrees Kelvin.

Using #2 I can see that I have 3 temperature probes in my laptop. I
can view their values in .NET using the following code. I apologize in
advance for using C# in VB forum.

// Reference the System.Management.dll assembly first.
using System.Management;

public class Temperature
{
public static void Main()
{
string scope = @"root\WMI";
string query = @"select * from MSAcpi_ThermalZoneTemperature";

ManagementObjectSearcher searcher = new
ManagementObjectSearcher(scope, query);

foreach (ManagementObject obj in searcher.Get())
{
Console.WriteLine(obj.Properties["CurrentTemperature"].Value);
}
}
}

Brian
 
Thanks,

I am able to use the following VB.NET code to get the temperature in my
development machine, but when I run in a XP Embedded machine, I got
"Provider Load Failure" error message for the first button, and "Invalid
parameter" for the second one. Any idea? Thanks for your knowledge!

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click

Dim moReturn As Management.ManagementObjectCollection

Dim moSearch As Management.ManagementObjectSearcher

Dim mo As Management.ManagementObject

Dim StrOutput As String

moSearch = New Management.ManagementObjectSearcher("root\cimv2", "Select *
from Win32_TemperatureProbe")

moReturn = moSearch.Get

For Each mo In moReturn

StrOutput = StrOutput & " " & mo("Name") & " " & mo("CurrentReading")

Next

MsgBox(StrOutput)

End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button5.Click

Dim moReturn As Management.ManagementObjectCollection

Dim moSearch As Management.ManagementObjectSearcher

Dim mo As Management.ManagementObject

Dim StrOutput As String

moSearch = New Management.ManagementObjectSearcher("root\WMI", "Select *
from MSAcpi_ThermalZoneTemperature")

moReturn = moSearch.Get

For Each mo In moReturn

StrOutput = StrOutput & " " &
Convert.ToString(Convert.ToUInt32(mo("CurrentTemperature")))

Next

MsgBox(StrOutput)

End Sub
 
I am able to use the following VB.NET code to get the temperature in my
development machine, but when I run in a XP Embedded machine, I got
"Provider Load Failure" error message for the first button, and "Invalid
parameter" for the second one. Any idea? Thanks for your knowledge!

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click

Dim moReturn As Management.ManagementObjectCollection

Dim moSearch As Management.ManagementObjectSearcher

Dim mo As Management.ManagementObject

Dim StrOutput As String

moSearch = New Management.ManagementObjectSearcher("root\cimv2", "Select *
from Win32_TemperatureProbe")

moReturn = moSearch.Get

For Each mo In moReturn

StrOutput = StrOutput & " " & mo("Name") & " " & mo("CurrentReading")

Next

MsgBox(StrOutput)

End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button5.Click

Dim moReturn As Management.ManagementObjectCollection

Dim moSearch As Management.ManagementObjectSearcher

Dim mo As Management.ManagementObject

Dim StrOutput As String

moSearch = New Management.ManagementObjectSearcher("root\WMI", "Select *
from MSAcpi_ThermalZoneTemperature")

moReturn = moSearch.Get

For Each mo In moReturn

StrOutput = StrOutput & " " &
Convert.ToString(Convert.ToUInt32(mo("CurrentTemperature")))

Next

MsgBox(StrOutput)

End Sub



Brian Gideon said:
Anthony,

You can use WMI if your hardware is compliant. Use the wbemtest.exe
utility to confirm whether or not you can even retrieve the
temperature. There are two ways I know of to retrieve the temperature
information.

1) Using wbemtest.exe connect to the namespace "root\cimv2" (without
quotes). Click the Query button and enter "select * from
Win32_TemperatureProbe". Double click on any result you get back and
look for the CurrentReading property in the properties section. The
value you see there should be the temperature. If it just shows
"<null>" then this option will not work.

2) Using wbemtest.ext connect to the namespace "root\WMI". Enter the
query "select * from MSAcpi_ThermalZoneTemperature". Double click on
any result you get back and look for the CurrentTemperature property.
The value is in tenths of degrees Kelvin.

Using #2 I can see that I have 3 temperature probes in my laptop. I
can view their values in .NET using the following code. I apologize in
advance for using C# in VB forum.

// Reference the System.Management.dll assembly first.
using System.Management;

public class Temperature
{
public static void Main()
{
string scope = @"root\WMI";
string query = @"select * from MSAcpi_ThermalZoneTemperature";

ManagementObjectSearcher searcher = new
ManagementObjectSearcher(scope, query);

foreach (ManagementObject obj in searcher.Get())
{
Console.WriteLine(obj.Properties["CurrentTemperature"].Value);
}
}
}

Brian
One the computer I am programmig I could see the CPU temperature in
the BIOS, is there a system DLL in VB.NET that I can call to
display the temperature in my software?

Thanks!
 
Hi,

When you look at the supported operating systems for
win32_temperatureprobe I see windows xp. I do not see xp embedded.

http://msdn.microsoft.com/library/d...y/en-us/wmisdk/wmi/win32_temperatureprobe.asp


Ken
------------------
I am able to use the following VB.NET code to get the temperature in my
development machine, but when I run in a XP Embedded machine, I got
"Provider Load Failure" error message for the first button, and "Invalid
parameter" for the second one. Any idea? Thanks for your knowledge!

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click

Dim moReturn As Management.ManagementObjectCollection

Dim moSearch As Management.ManagementObjectSearcher

Dim mo As Management.ManagementObject

Dim StrOutput As String

moSearch = New Management.ManagementObjectSearcher("root\cimv2", "Select *
from Win32_TemperatureProbe")

moReturn = moSearch.Get

For Each mo In moReturn

StrOutput = StrOutput & " " & mo("Name") & " " & mo("CurrentReading")

Next

MsgBox(StrOutput)

End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button5.Click

Dim moReturn As Management.ManagementObjectCollection

Dim moSearch As Management.ManagementObjectSearcher

Dim mo As Management.ManagementObject

Dim StrOutput As String

moSearch = New Management.ManagementObjectSearcher("root\WMI", "Select *
from MSAcpi_ThermalZoneTemperature")

moReturn = moSearch.Get

For Each mo In moReturn

StrOutput = StrOutput & " " &
Convert.ToString(Convert.ToUInt32(mo("CurrentTemperature")))

Next

MsgBox(StrOutput)

End Sub



Brian Gideon said:
Anthony,

You can use WMI if your hardware is compliant. Use the wbemtest.exe
utility to confirm whether or not you can even retrieve the
temperature. There are two ways I know of to retrieve the temperature
information.

1) Using wbemtest.exe connect to the namespace "root\cimv2" (without
quotes). Click the Query button and enter "select * from
Win32_TemperatureProbe". Double click on any result you get back and
look for the CurrentReading property in the properties section. The
value you see there should be the temperature. If it just shows
"<null>" then this option will not work.

2) Using wbemtest.ext connect to the namespace "root\WMI". Enter the
query "select * from MSAcpi_ThermalZoneTemperature". Double click on
any result you get back and look for the CurrentTemperature property.
The value is in tenths of degrees Kelvin.

Using #2 I can see that I have 3 temperature probes in my laptop. I
can view their values in .NET using the following code. I apologize in
advance for using C# in VB forum.

// Reference the System.Management.dll assembly first.
using System.Management;

public class Temperature
{
public static void Main()
{
string scope = @"root\WMI";
string query = @"select * from MSAcpi_ThermalZoneTemperature";

ManagementObjectSearcher searcher = new
ManagementObjectSearcher(scope, query);

foreach (ManagementObject obj in searcher.Get())
{
Console.WriteLine(obj.Properties["CurrentTemperature"].Value);
}
}
}

Brian
One the computer I am programmig I could see the CPU temperature in
the BIOS, is there a system DLL in VB.NET that I can call to
display the temperature in my software?

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top