
Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
It is more complicated as I though. Any way thanks for the input. I am also
reading about the System.Management namespace and the ManagementEventWatcher.
I will have a look on both ideas
> >Is there any class that watch for the logical drives installed in the
> >computer.
[quoted text clipped - 3 lines]
>
> Mattias
Willy Denoyette [MVP] - 06 Jul 2005 11:25 GMT
Yes, the Management classes are the way to go.
You can register an ManagementEventWatcher for 'Win32_USBControllerDevice'
instance arrivals, sometyhing like this will do:
....
WqlEventQuery q = new WqlEventQuery();
q.EventClassName = "__InstanceOperationEvent";
q.WithinInterval = new TimeSpan(0,0,3);
q.Condition = @"TargetInstance ISA 'Win32_USBControllerDevice' ";
w = new ManagementEventWatcher(q);
w.EventArrived += new EventArrivedEventHandler(this.UsbEventArrived);
w.Start(); // Start listen for events
public void UsbEventArrived(object sender, EventArrivedEventArgs e) {
... // Handle the event
}
Willy.
> It is more complicated as I though. Any way thanks for the input. I am
> also
[quoted text clipped - 11 lines]
>>
>> Mattias