Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Visual Basic .NET (http://www.programmingforums.org/forum19.html)
-   -   Temperature Controls (http://www.programmingforums.org/showthread.php?t=14853)

mattireland Jan 2nd, 2008 2:53 PM

Temperature Controls
 
Hi,

I'm wanting to make a temperature monitoring application like speedfan or coretemp and was just wondering how to monitor the temperature. Is there a certain control - I've tried googling for a class or something and I just can't find anything.

Thanks very, very much!

Matt. I

mrynit Jan 2nd, 2008 11:47 PM

Re: Temperature Controls
 
do you actualy want to interface with hardware?

mattireland Jan 3rd, 2008 3:57 AM

Re: Temperature Controls
 
Yes, I think it would be nice. Why would you not recommend it? Is there something bad I'm missing?

Thanks for the reply!

Sane Jan 6th, 2008 7:19 AM

Re: Temperature Controls
 
Here's a link to a discussion about how to do it in Linux. Although you're not doing this in Linux, I'm sure that either some of the libraries are cross-compatible and/or you can use this thread as a stepping stone to finding the correct library.

Good luck.

milot Jan 6th, 2008 9:53 AM

Re: Temperature Controls
 
You can use WMI (Windows Management Instrumentation) Classes and use the Win32_TemperatureProbe WMI Class to get that information you need, here is a code snippet that shows how to use WMI on C#, you can easily convert this to VB:

the code:

:

  1. using System;
  2. using System.Management;
  3. using System.Management.Instrumentation;
  4.  
  5. public class BClass
  6. {
  7.  
  8.     public static void Main(string[] args)
  9.     {
  10.         ManagementObjectSearcher objectSearcher = new ManagementObjectSearcher("SELECT * FROM Win32_TemperatureProbe");
  11.  
  12.         foreach (ManagementObject obj in objectSearcher.Get())
  13.             Console.WriteLine(obj["Status"]);
  14.     }
  15. }


You can use other properties as listed below:
http://msdn2.microsoft.com/en-us/lib...93(VS.85).aspx

but note that, you will need a bit of research because of the manufacturer drivers, on my laptop it doesn't work because I don't have appropriate drivers because I have an apple mac book so it doesn't show anything, but you can read here for more information:
http://groups.google.de/groups?q=cpu+temperature+dotnet

you can browse other WMI Classes to use for other purposes (see the list on the left)

mattireland Jan 6th, 2008 11:58 AM

Re: Temperature Controls
 
Thanks! The C# was helpful!

There are two ways (almost the same) I managed to find (with some help) in VB.NET:

:

Imports System
Imports System.Management

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 ex As ManagementException
        '    MessageBox.Show(ex.Message)
        'End Try

        Dim tempReturn As Management.ManagementObjectCollection

        Dim tempSearch As Management.ManagementObjectSearcher

        Dim temp As Management.ManagementObject

        Dim StrOut As String

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

        tempReturn = tempSearch.Get

        For Each mo In tempReturn

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

        Next

        MsgBox(StrOut)

    End Sub

End Class


Unfortunately, they don't work for me either. Is there any way that you know that I can get the drivers to make them work/include them in the application?

Thanks!

Matt. I

milot Jan 6th, 2008 7:54 PM

Re: Temperature Controls
 
Well I did a bit of research on "why-wmi-doesn't-support-Win32_TemperatureProbe" and figured out that WMI doesn't support this feature right now, but it will in the near future, but I saw that this guy -> http://geekswithblogs.net/cicorias/a.../22/97855.aspx wrote a little software for temperature monitor and you can download its source code, but I downloaded the installer and when I open the main assembly it throws an exception see the picture below:

http://img514.imageshack.us/img514/3...pportedej0.png

because he used the same techniques that we discussed above this post. So keep googling and if you find something useful, notify us, in meantime I will try finding the solution and will reply for notification.


All times are GMT -5. The time now is 9:15 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC