diff options
Diffstat (limited to 'devicelist/Program.cs')
| -rw-r--r-- | devicelist/Program.cs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/devicelist/Program.cs b/devicelist/Program.cs new file mode 100644 index 0000000..6ac08f6 --- /dev/null +++ b/devicelist/Program.cs @@ -0,0 +1,27 @@ +using System; +using System.Text; +using System.Management; +using System.Windows.Forms; + +namespace devicelist +{ + class Program + { + static void Main(string[] args) + { + ManagementObjectSearcher searcher = new ManagementObjectSearcher(new SelectQuery("Win32_PnPEntity")); + + foreach (ManagementObject obj in searcher.Get()) + { + if (obj["PNPClass"].ToString() == "Mouse" && obj["HardwareID"] != null) { + String[] hwidArray = (String[])(obj["HardwareID"]); + String hwid = hwidArray[0].ToString().Replace(@"\", @"\\"); + String caption = "(" + obj["Name"].ToString() + ") Device Hardware ID:"; + if (MessageBox.Show(hwid, caption, MessageBoxButtons.OKCancel) == DialogResult.Cancel) { + break; + } + } + } + } + } +} |