I have a USB device and a C# application communicating with it.
Presently I am using a connect button to connect with the device from my application. This is a HID device and on Connect I will register for change notifications and from then onwards my application can display 'DEVICE ON LINE" or off line and act upon, based on windows WM_DEVICECHANGE message.
But I need to avoid this 'Connect' button!
What I need is to call my HIDdevice find and connect function upon a device plugging in. Then it seems OK.
So I am trapping this WM_DEVICECHANGE message.
When the application starts if the device is not present , I wont be able register it for notifications.(Am I correct?) So the device is not registered and when the device plugs in , I am getting windows message with wparam value 7 (Means a device is plugged or unplugged!).Actually that is all I needed to call my function.But I am getting 3 or 4 messages in sequence - all with wparam as 7.
How I can solve this?
Thanks