Hi,
This will only work on Windows XP!!! Here is a real simple
example. Add a reference to system.management
Imports System.Management
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Dim WithEvents w As ManagementEventWatcher
Dim q As WqlEventQuery
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
q = New WqlEventQuery("Select * from Win32_DeviceChangeEvent")
w = New ManagementEventWatcher(q)
w.Start()
End Sub
Private Sub w_EventArrived(ByVal sender As Object, ByVal e As
System.Management.EventArrivedEventArgs) Handles w.EventArrived
MessageBox.Show("Device Event")
End Sub
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
w.Stop()
End Sub
End Class
Ken
---------------------
"Charles Law" <bl***@nowhere.com> wrote in message
news:uX**************@TK2MSFTNGP09.phx.gbl...
Is there an event or notification that my application can receive when a
USB device (or other) is plugged in?
I have looked at WMI as this appears to be the right area but cannot see
how to get notification when this particular event occurs. The same goes for
removal as well.
TIA
Charles