I have play around about WqlEventQuery in purpose to identify a device plugged in USB
var query = new WqlEventQuery();
query.EventClassName = "__InstanceOperationEvent";
query.WithinInterval = new TimeSpan(0, 0, 2);
query.Condition = @"TargetInstance ISA 'Win32_USBControllerdevice'";
using (var watcher = new ManagementEventWatcher(query))
{
watcher.EventArrived += WatcherEvent;
watcher.Start();
... Wait condition ...
watcher.Stop();
}
then I tried to look for device property in the watcher event handler
foreach (var mbo in e.NewEvent.Properties.Cast<PropertyData>().Where(i => i.Value != null && i.Value is ManagementBaseObject).Select(pdData => (ManagementBaseObject)pdData.Value).Where(mbo => mbo != null))
{
if (mbo.ClassPath.ClassName == "Win32_USBControllerDevice")
{
foreach (var prop in mbo.SystemProperties)
{
... look for the property content
}
}
}
but could not found a place where I could extract information about plugged device. So when I am plugging a phone over the USB Port. I want to extract information that states that is a phone of a particular model from the particular producer and so on.
Am I am going the right things in purpose to get this information? should I try something different or more effective in this regards?
Thanks!