narmi2
asked on
WMI - Win32_DeviceChangeEvent - Help
Hi
I am trying to detect when a device is plugged in to removed from my computer
Start Code---------------------- --------
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.EventArr ivedEventA rgs) Handles w.EventArrived
MessageBox.Show("New Arrival")
End Sub
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_devicechangeevent.asp
End Code---------------------- ---------- -
According to this site: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_devicechangeevent.asp, Device Arrival has a value of 2 and Device Removal has a value of 3!
How do I use this information to display a different message box for value? e.g.
When the value is 2 (Device Arrival) do messagebox1.show("New Device Detected")
When the value is 3 (Device Removal) do messagebox1.show("Device Removed")
Anyone know how to do this?
Thanks
I am trying to detect when a device is plugged in to removed from my computer
Start Code----------------------
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.EventArr
MessageBox.Show("New Arrival")
End Sub
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_devicechangeevent.asp
End Code----------------------
According to this site: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_devicechangeevent.asp, Device Arrival has a value of 2 and Device Removal has a value of 3!
How do I use this information to display a different message box for value? e.g.
When the value is 2 (Device Arrival) do messagebox1.show("New Device Detected")
When the value is 3 (Device Removal) do messagebox1.show("Device Removed")
Anyone know how to do this?
Thanks
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.