summaryrefslogtreecommitdiff
path: root/grapher/Models/Devices
diff options
context:
space:
mode:
authorTomáš Pazdiora <[email protected]>2021-01-07 23:21:33 +0100
committerTomáš Pazdiora <[email protected]>2021-01-07 23:21:33 +0100
commit215a21f9b62aa50d9ca4037ca0a22f5b0920f373 (patch)
tree3f0cbca12e4575cc325c86996d952d01829b2acd /grapher/Models/Devices
parentupdate devicelist app (diff)
downloadrawaccel-215a21f9b62aa50d9ca4037ca0a22f5b0920f373.tar.xz
rawaccel-215a21f9b62aa50d9ca4037ca0a22f5b0920f373.zip
rough GUI integration of "Device Hardware ID"
Diffstat (limited to 'grapher/Models/Devices')
-rw-r--r--grapher/Models/Devices/DeviceList.cs33
1 files changed, 33 insertions, 0 deletions
diff --git a/grapher/Models/Devices/DeviceList.cs b/grapher/Models/Devices/DeviceList.cs
new file mode 100644
index 0000000..9f2b81d
--- /dev/null
+++ b/grapher/Models/Devices/DeviceList.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Management;
+using System.Collections.Generic;
+
+namespace grapher.Models.Devices
+{
+ class DeviceList
+ {
+ public static List<Tuple<string, string>> GetDeviceHardwareIDs(string PNPClass = "Mouse")
+ {
+ var results = new List<Tuple<string, string>>();
+
+ ManagementObjectSearcher searcher = new ManagementObjectSearcher(new SelectQuery("Win32_PnPEntity"));
+
+ foreach (ManagementObject obj in searcher.Get())
+ {
+ if (obj["PNPClass"] != null && obj["PNPClass"].ToString() == PNPClass && obj["HardwareID"] != null)
+ {
+ String[] hwidArray = (String[])(obj["HardwareID"]);
+ if (hwidArray.Length > 0)
+ {
+ String hwid = hwidArray[0].ToString();
+ String name = obj["Name"].ToString();
+ results.Add(Tuple.Create(name, hwid));
+ }
+ }
+ }
+
+ return results;
+ }
+
+ }
+}