Hello,
I am using windows broadcast message to detect when USB device (EZ web cam) is connected and when it is removed.
I have a code that override the WinProc fucntion which gets called once when I connect USB device, this is probably for the WM_DEVICEARRIVAL event.
The same function is called two times when I disconnect the USB device. This is probably for WM_DEVICEREMOVAL and WM_DEVICEREMOVALCOMPLETE events.
For some reason when I set breakpoint in this function then I see same value of &H7 for m.WParam.ToInt32() for all these three events. Is there anything I am missing which causes same value for m.WParam member?
Below is my code snippet. Thanks.
++++++++++++++++++
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
Dim index As Int32
If m.Msg = &H219 Then ' WM_DEVICECHANGE
If (m.WParam.ToInt32() = &H8000) Then
MsgBox("Device Arrival!")
End If
If (m.WParam.ToInt32() = &H8004) Then
MsgBox("Device Removed!")
End If
End If
MyBase.WndProc(m)
End Sub
+++++++++++++++++++++++++++++++++++++++++
I am using windows broadcast message to detect when USB device (EZ web cam) is connected and when it is removed.
I have a code that override the WinProc fucntion which gets called once when I connect USB device, this is probably for the WM_DEVICEARRIVAL event.
The same function is called two times when I disconnect the USB device. This is probably for WM_DEVICEREMOVAL and WM_DEVICEREMOVALCOMPLETE events.
For some reason when I set breakpoint in this function then I see same value of &H7 for m.WParam.ToInt32() for all these three events. Is there anything I am missing which causes same value for m.WParam member?
Below is my code snippet. Thanks.
++++++++++++++++++
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
Dim index As Int32
If m.Msg = &H219 Then ' WM_DEVICECHANGE
If (m.WParam.ToInt32() = &H8000) Then
MsgBox("Device Arrival!")
End If
If (m.WParam.ToInt32() = &H8004) Then
MsgBox("Device Removed!")
End If
End If
MyBase.WndProc(m)
End Sub
+++++++++++++++++++++++++++++++++++++++++