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.