4
在试图开发硬盘分析工具时,我试图从硬盘的SMART数据中获取加载/卸载周期数的值,我想知道是否有人知道如何做到这一点。 我想要:使用SMART和WMI加载/卸载周期数
- 我搜索WMI
MSStorageDriver_ATAPISmartData
类数据,其中属性数量193是我需要 - 的数据我收到的外观(占加载/卸载循环次数的属性)像
我觉得我很近,红色的数据是一样的东西珠峰家庭版显示了当我运行它,理想我想最后一部分是(属性称为数据)
用于收集该数据方法:
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.这种方法适用于收集硬盘的温度(这是什么Console.WriteLine("HDD TEMP: " + arrVendorSpecific[tempIndex + 5].ToString());
线是关于,但我不知道为什么它的tempIndex + 5