CPU Temperature

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • anthony

    #1

    CPU Temperature

    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!


  • Herfried K. Wagner [MVP]

    #2
    Re: CPU Temperature

    "anthony" <anthonyho@cont rolengineer.com > schrieb:[color=blue]
    > 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?[/color]

    <URL:http://www.google.es/groups?q=Win32_ TemperatureProb e+dotnet+-herfried>

    --
    M S Herfried K. Wagner
    M V P <URL:http://dotnet.mvps.org/>
    V B <URL:http://classicvb.org/petition/>

    Comment

    • Brian Gideon

      #3
      Re: CPU Temperature

      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_Temperatu reProbe". 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_ThermalZ oneTemperature" . Double click on
      any result you get back and look for the CurrentTemperat ure 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.Manageme nt.dll assembly first.
      using System.Manageme nt;

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

      ManagementObjec tSearcher searcher = new
      ManagementObjec tSearcher(scope , query);

      foreach (ManagementObje ct obj in searcher.Get())
      {
      Console.WriteLi ne(obj.Properti es["CurrentTempera ture"].Value);
      }
      }
      }

      Brian

      anthony wrote:[color=blue]
      > 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![/color]

      Comment

      • anthony

        #4
        Re: CPU Temperature

        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(B yVal sender As System.Object, ByVal e As
        System.EventArg s) Handles Button4.Click

        Dim moReturn As Management.Mana gementObjectCol lection

        Dim moSearch As Management.Mana gementObjectSea rcher

        Dim mo As Management.Mana gementObject

        Dim StrOutput As String

        moSearch = New Management.Mana gementObjectSea rcher("root\cim v2", "Select *
        from Win32_Temperatu reProbe")

        moReturn = moSearch.Get

        For Each mo In moReturn

        StrOutput = StrOutput & " " & mo("Name") & " " & mo("CurrentRead ing")

        Next

        MsgBox(StrOutpu t)

        End Sub

        Private Sub Button5_Click(B yVal sender As System.Object, ByVal e As
        System.EventArg s) Handles Button5.Click

        Dim moReturn As Management.Mana gementObjectCol lection

        Dim moSearch As Management.Mana gementObjectSea rcher

        Dim mo As Management.Mana gementObject

        Dim StrOutput As String

        moSearch = New Management.Mana gementObjectSea rcher("root\WMI ", "Select *
        from MSAcpi_ThermalZ oneTemperature" )

        moReturn = moSearch.Get

        For Each mo In moReturn

        StrOutput = StrOutput & " " &
        Convert.ToStrin g(Convert.ToUIn t32(mo("Current Temperature")))

        Next

        MsgBox(StrOutpu t)

        End Sub



        "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
        news:eiWl6FNVFH A.2128@TK2MSFTN GP15.phx.gbl...[color=blue]
        > "anthony" <anthonyho@cont rolengineer.com > schrieb:[color=green]
        > > 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?[/color]
        >
        >[/color]
        <URL:http://www.google.es/groups?q=Win32_ TemperatureProb e+dotnet+-herfried>[color=blue]
        >
        > --
        > M S Herfried K. Wagner
        > M V P <URL:http://dotnet.mvps.org/>
        > V B <URL:http://classicvb.org/petition/>[/color]


        Comment

        • anthony

          #5
          Re: CPU Temperature

          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(B yVal sender As System.Object, ByVal e As
          System.EventArg s) Handles Button4.Click

          Dim moReturn As Management.Mana gementObjectCol lection

          Dim moSearch As Management.Mana gementObjectSea rcher

          Dim mo As Management.Mana gementObject

          Dim StrOutput As String

          moSearch = New Management.Mana gementObjectSea rcher("root\cim v2", "Select *
          from Win32_Temperatu reProbe")

          moReturn = moSearch.Get

          For Each mo In moReturn

          StrOutput = StrOutput & " " & mo("Name") & " " & mo("CurrentRead ing")

          Next

          MsgBox(StrOutpu t)

          End Sub

          Private Sub Button5_Click(B yVal sender As System.Object, ByVal e As
          System.EventArg s) Handles Button5.Click

          Dim moReturn As Management.Mana gementObjectCol lection

          Dim moSearch As Management.Mana gementObjectSea rcher

          Dim mo As Management.Mana gementObject

          Dim StrOutput As String

          moSearch = New Management.Mana gementObjectSea rcher("root\WMI ", "Select *
          from MSAcpi_ThermalZ oneTemperature" )

          moReturn = moSearch.Get

          For Each mo In moReturn

          StrOutput = StrOutput & " " &
          Convert.ToStrin g(Convert.ToUIn t32(mo("Current Temperature")))

          Next

          MsgBox(StrOutpu t)

          End Sub



          "Brian Gideon" <briangideon@ya hoo.com> wrote in message
          news:1115669705 .913333.132120@ z14g2000cwz.goo glegroups.com.. .[color=blue]
          > 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_Temperatu reProbe". 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_ThermalZ oneTemperature" . Double click on
          > any result you get back and look for the CurrentTemperat ure 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.Manageme nt.dll assembly first.
          > using System.Manageme nt;
          >
          > public class Temperature
          > {
          > public static void Main()
          > {
          > string scope = @"root\WMI";
          > string query = @"select * from MSAcpi_ThermalZ oneTemperature" ;
          >
          > ManagementObjec tSearcher searcher = new
          > ManagementObjec tSearcher(scope , query);
          >
          > foreach (ManagementObje ct obj in searcher.Get())
          > {
          > Console.WriteLi ne(obj.Properti es["CurrentTempera ture"].Value);
          > }
          > }
          > }
          >
          > Brian
          >
          > anthony wrote:[color=green]
          > > 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![/color]
          >[/color]


          Comment

          • Ken Tucker [MVP]

            #6
            Re: CPU Temperature

            Hi,

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

            http://msdn.microsoft.com/library/de...atureprobe.asp


            Ken
            ------------------
            "anthony" <anthonyho@cont rolengineer.com > wrote in message
            news:OO8PWKPVFH A.3620@TK2MSFTN GP09.phx.gbl...
            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(B yVal sender As System.Object, ByVal e As
            System.EventArg s) Handles Button4.Click

            Dim moReturn As Management.Mana gementObjectCol lection

            Dim moSearch As Management.Mana gementObjectSea rcher

            Dim mo As Management.Mana gementObject

            Dim StrOutput As String

            moSearch = New Management.Mana gementObjectSea rcher("root\cim v2", "Select *
            from Win32_Temperatu reProbe")

            moReturn = moSearch.Get

            For Each mo In moReturn

            StrOutput = StrOutput & " " & mo("Name") & " " & mo("CurrentRead ing")

            Next

            MsgBox(StrOutpu t)

            End Sub

            Private Sub Button5_Click(B yVal sender As System.Object, ByVal e As
            System.EventArg s) Handles Button5.Click

            Dim moReturn As Management.Mana gementObjectCol lection

            Dim moSearch As Management.Mana gementObjectSea rcher

            Dim mo As Management.Mana gementObject

            Dim StrOutput As String

            moSearch = New Management.Mana gementObjectSea rcher("root\WMI ", "Select *
            from MSAcpi_ThermalZ oneTemperature" )

            moReturn = moSearch.Get

            For Each mo In moReturn

            StrOutput = StrOutput & " " &
            Convert.ToStrin g(Convert.ToUIn t32(mo("Current Temperature")))

            Next

            MsgBox(StrOutpu t)

            End Sub



            "Brian Gideon" <briangideon@ya hoo.com> wrote in message
            news:1115669705 .913333.132120@ z14g2000cwz.goo glegroups.com.. .[color=blue]
            > 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_Temperatu reProbe". 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_ThermalZ oneTemperature" . Double click on
            > any result you get back and look for the CurrentTemperat ure 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.Manageme nt.dll assembly first.
            > using System.Manageme nt;
            >
            > public class Temperature
            > {
            > public static void Main()
            > {
            > string scope = @"root\WMI";
            > string query = @"select * from MSAcpi_ThermalZ oneTemperature" ;
            >
            > ManagementObjec tSearcher searcher = new
            > ManagementObjec tSearcher(scope , query);
            >
            > foreach (ManagementObje ct obj in searcher.Get())
            > {
            > Console.WriteLi ne(obj.Properti es["CurrentTempera ture"].Value);
            > }
            > }
            > }
            >
            > Brian
            >
            > anthony wrote:[color=green]
            > > 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![/color]
            >[/color]



            Comment

            Working...