Answer the question
In order to leave comments, you need to log in
How to programmatically get a list of all device properties in Device Manager?
Hi all!
There was an idea to write an application similar to USBDeview (an application that displays all currently connected USB devices). I also want to implement the functionality of turning on / off the USB device according to the schedule (USBDeview can also do this). All manipulations are carried out through requests to WMI. Faced a number of problems:
1. When you connect a new USB device, two devices appear - USB Mass Storage Device and Disk Drive. Which one to turn on / off so that the USB device is properly disconnected?
2. The request "select * from Win32_PnpEntity" returns a rather meager set of properties (for example, the parameters I need are missing, such as Matching device Id, Class, Is connected, etc. - all these parameters are in the Device Manager'e in the Details tab) . This is where the question comes from. How to display ALL properties that are in Device Manager'e?
Small code example:
using System;
using System.Management;
namespace TestRequest
{
class Program
{
static void Main(string[] args)
{
ManagementObjectCollection collection;
using (var searcher = new ManagementObjectSearcher(@"Select * From Win32_PnpEntity"))
collection = searcher.Get();
foreach (var device in collection)
{
Console.WriteLine("===================================");
foreach (var prop in device.Properties)
Console.WriteLine("\t{0} : {1}", prop.Name, prop.Value);
Console.WriteLine("===================================");
}
collection.Dispose();
Console.Read();
}
}
}
Answer the question
In order to leave comments, you need to log in
1. To disable, use USB Mass Storage Device
2. For more information about devices, use the query: "Select * From Win32_USBHub"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question