Added used space load sensors for hard drives.

This commit is contained in:
Michael Möller
2012-07-22 18:07:11 +00:00
parent a53679c3ad
commit 5e87af437d
5 changed files with 67 additions and 4 deletions

View File

@@ -12,6 +12,7 @@
using System;
using System.Collections.Generic;
using System.Management;
using System.Runtime.InteropServices;
namespace OpenHardwareMonitor.Hardware.HDD {
@@ -341,6 +342,23 @@ namespace OpenHardwareMonitor.Hardware.HDD {
NativeMethods.CloseHandle(handle);
}
public string[] GetLogicalDrives(int driveIndex) {
List<string> list = new List<string>();
try {
using (ManagementObjectSearcher s = new ManagementObjectSearcher(
"root\\CIMV2",
"SELECT * FROM Win32_DiskPartition " +
"WHERE DiskIndex = " + driveIndex))
using (ManagementObjectCollection dpc = s.Get())
foreach (ManagementObject dp in dpc)
using (ManagementObjectCollection ldc =
dp.GetRelated("Win32_LogicalDisk"))
foreach (ManagementBaseObject ld in ldc)
list.Add(((string)ld["Name"]).TrimEnd(':'));
} catch { }
return list.ToArray();
}
protected static class NativeMethods {
private const string KERNEL = "kernel32.dll";