Hi Brad,
Here is a sample.
'===========================================================================
=====
Dim watcher As System.Management.ManagementEventWatcher
Public Sub StartListen()
watcher = New System.Management.ManagementEventWatcher
watcher.Query = New System.Management.EventQuery("SELECT * FROM
__InstanceCreationEvent WITHIN 1 WHERE TargetInstance ISA
'Win32_PnPEntity'")
AddHandler watcher.EventArrived, AddressOf NewPlugPlay
watcher.Start()
End Sub
Public Sub StopListen()
watcher.Stop()
End Sub
Public Sub NewPlugPlay(ByVal sender As Object, ByVal e As
EventArrivedEventArgs)
Console.WriteLine("New Plug and Play = " +
(CType(e.NewEvent("TargetInstance"), ManagementBaseObject))("Caption"))
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
StartListen()
End Sub
'===========================================================================
=====
If you have any concern on this issue,please post here.
Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure!
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.