0

I'm having trouble getting the right temperature out of a certain hard drive on my application using a WMI query, somehow one of my two hard drives gets 0 back as temperature, while the other one returns a regular temperature such as 34 degrees celsius.

This is my method:

public static void GetTemps()
    {
        const byte TEMPERATURE_ATTRIBUTE = 194; 
        try
        {
            int counter = 1;
            ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\WMI", "SELECT * FROM MSStorageDriver_ATAPISmartData");
            foreach (ManagementObject queryObj in searcher.Get())
            {
                byte[] arrVendorSpecific = (byte[])queryObj["VendorSpecific"];
                System.Windows.Forms.MessageBox.Show("DRIVE: " + (counter + ("=" + arrVendorSpecific[TEMPERATURE_ATTRIBUTE + 5])));
                counter++;
            }
        }
        catch (ManagementException err)
        {
            System.Windows.Forms.MessageBox.Show(("An error has occurred: " + err.Message));
        }

Perhaps the oddest part, is that this code used to work not long ago, although it would still show up a 0 every now and then.

user1676874
  • 875
  • 2
  • 24
  • 45
  • 2
    Maybe the temperature *is* zero. – rory.ap Oct 13 '16 at 20:01
  • Well I have also used other tools, such as Open Hardware Monitor, and they do report actual believable temps. – user1676874 Oct 13 '16 at 20:05
  • 1
    what's the `+ 5` for in `arrVendorSpecific`? – Jacob Krall Oct 13 '16 at 21:07
  • You might be looking at the wrong value, maybe do something that might cause your hard drive to get warmer like running windirstat and iterating over each byte value in `arrVendorSpecific`, and while you do that, check to see which values are changing in your byte array. I tried it, but my SSD only seems to be reporting 50C consistently on this laptop. – KSib Oct 13 '16 at 21:44
  • Possible duplicate of [How can I use C# To read extended smart data?](http://stackoverflow.com/questions/8663980/how-can-i-use-c-sharp-to-read-extended-smart-data) – JosefZ Oct 14 '16 at 21:43

0 Answers0