In an attempt to develop a hard disk analytic tool, I’m trying to get the value of Load/Unload cycle count from my hard disk’s S.M.A.R.T data, I’m wondering if anyone knows how to do this.
What I’m trying:
- I’m searching the WMI
MSStorageDriver_ATAPISmartDataclass data where attribute number 193 is what i need (the attribute representing load/unload cycle count) - The data I’m getting looks like

I think I’m close, the data in red is the same as what Everest Home edition is showing when i run it, ideally i would want the last part which is (attribute called data)

Method for collecting this data:
static void doStuff()
{
try
{
byte TEMPERATURE_ATTRIBUTE = 193;
ManagementObjectSearcher searcher = new ManagementObjectSearcher(@"\root\WMI", "SELECT * FROM MSStorageDriver_ATAPISmartData");
//loop through all the hard disks
foreach (ManagementObject queryObj in searcher.Get())
{
byte[] arrVendorSpecific = (byte[])queryObj.GetPropertyValue("VendorSpecific");
int tempIndex = Array.IndexOf(arrVendorSpecific, TEMPERATURE_ATTRIBUTE);
Console.WriteLine("HDD TEMP: " + arrVendorSpecific[tempIndex + 5].ToString());
foreach (byte dat in arrVendorSpecific)
{
Console.Write(dat.ToString() + " ");
}
}
}
catch (Exception err) { Console.WriteLine(err.Message); }
}
P.S. this method works for collecting the HDD’s temperature (that’s what the Console.WriteLine("HDD TEMP: " + arrVendorSpecific[tempIndex + 5].ToString()); line is all about but I’m not sure why its tempIndex+5
The code which you are using is not correct, because you are using a secuencial search (Array.IndexOf) to find the S.M.A.R.T
Attribute ID(you can have false positives because that value can match with another in the array), the ID of these attibutes has an fixed position inside of an documented structure (SMART Attribute Overview).SMART Attribute Table
Entry in the Attribute Table
from here you can write a code to search the location of each attribute and get the values which you are looking for