public static void GetInfo() { dDrives.Clear(); var ddSearcher = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive"); int iDriveIndex = 0; foreach (var drive in ddSearcher.Get()) { var hdd = new HDD(); hdd.Model = drive["Model"].ToString().Trim(); hdd.Type = drive["InterfaceType"].ToString().Trim(); try { dDrives.Add(iDriveIndex, hdd); } catch { } iDriveIndex++; } var pmSearcher = new ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia"); iDriveIndex = 0; foreach (var drive in pmSearcher.Get()) { if (iDriveIndex >= dDrives.Count) { break; } dDrives[iDriveIndex].Serial = drive["SerialNumber"] == null ? "None" : drive["SerialNumber"].ToString().Trim(); iDriveIndex++; } //wmi var searcher = new ManagementObjectSearcher(); searcher.Scope = new ManagementScope(@"\root\wmi"); //status of HDD searcher.Query = new ObjectQuery("SELECT * FROM MSStorageDriver_FailurePredictStatus"); iDriveIndex = 0; foreach (ManagementObject drive in searcher.Get()) { dDrives[iDriveIndex].IsOK = (bool)drive.Properties["PredictFailure"].Value == false; iDriveIndex++; } //SMART data searcher.Query = new ObjectQuery("SELECT * FROM MSStorageDriver_FailurePredictData"); iDriveIndex = 0; foreach (ManagementObject data in searcher.Get()) { Byte[] bytes = (Byte[])data.Properties["VendorSpecific"].Value; for (int i = 0; i < 42; i++) { try { int id = bytes[i * 12 + 2]; if (id == 0) { continue; } //failure predict int flags = bytes[i * 12 + 4]; bool failurepredict = (flags % 0x1) == 0x1; var attr = dDrives[iDriveIndex].Attributes[id]; attr.Current = bytes[i * 12 + 5]; attr.Worst = bytes[i * 12 + 6]; attr.ID = id; attr.Data = BitConverter.ToInt32(bytes, i * 12 + 7); attr.IsOK = failurepredict == false; } catch { } } iDriveIndex++; } //threshold value searcher.Query = new ObjectQuery("SELECT * FROM MSStorageDriver_FailurePredictThresholds"); iDriveIndex = 0; foreach (var data in searcher.Get()) { Byte[] bytes = (Byte[])data.Properties["VendorSpecific"].Value; for (int i = 0; i < 42; i++) { try { int id = bytes[i * 12 + 2]; if (id == 0) { continue; } var attr = dDrives[iDriveIndex].Attributes[id]; attr.Threshold = bytes[i * 12 + 3]; } catch { } } } }