From 97e0a9c86faa57754860c7661b66a80f49d4939e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=B6ller?= Date: Sun, 30 Jun 2013 16:24:52 +0000 Subject: [PATCH] Changed the HDD enumeration code to drop drives without smart support and without any non-zero-sized logical drives. --- Hardware/HDD/AbstractHarddrive.cs | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/Hardware/HDD/AbstractHarddrive.cs b/Hardware/HDD/AbstractHarddrive.cs index 3bcefb8..d1f10d8 100644 --- a/Hardware/HDD/AbstractHarddrive.cs +++ b/Hardware/HDD/AbstractHarddrive.cs @@ -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))