Changed the HDD enumeration code to drop drives without smart support and without any non-zero-sized logical drives.

This commit is contained in:
Michael Möller 2013-06-30 16:24:52 +00:00
parent 67354b4125
commit 97e0a9c86f

View File

@ -69,9 +69,12 @@ namespace OpenHardwareMonitor.Hardware.HDD {
foreach (string logicalDrive in logicalDrives) {
try {
DriveInfo di = new DriveInfo(logicalDrive);
if (di.TotalSize > 0)
if (di.TotalSize > 0)
driveInfoList.Add(new DriveInfo(logicalDrive));
} catch (ArgumentException) { } catch (IOException) { }
} catch (ArgumentException) {
} catch (IOException) {
} catch (UnauthorizedAccessException) {
}
}
driveInfos = driveInfoList.ToArray();
@ -105,6 +108,23 @@ namespace OpenHardwareMonitor.Hardware.HDD {
string[] logicalDrives = smart.GetLogicalDrives(driveIndex);
if (logicalDrives == null || logicalDrives.Length == 0)
return null;
bool hasNonZeroSizeDrive = false;
foreach (string logicalDrive in logicalDrives) {
try {
DriveInfo di = new DriveInfo(logicalDrive);
if (di.TotalSize > 0) {
hasNonZeroSizeDrive = true;
break;
}
} catch (ArgumentException) {
} catch (IOException) {
} catch (UnauthorizedAccessException) {
}
}
if (!hasNonZeroSizeDrive)
return null;
}
if (string.IsNullOrEmpty(name))