mirror of
https://github.com/openhardwaremonitor/openhardwaremonitor
synced 2025-08-31 06:15:08 +00:00
Added used space load sensors for hard drives.
This commit is contained in:
@@ -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";
|
||||
|
||||
|
Reference in New Issue
Block a user