Eimund
asked on
RegisterDeviceNotification(), how to capture the messages?
Hello,
I'm trying to use the function RegisterDeviceNotification to handle when a USB device attaches or removes.
I have made my own class, CUSB, which contain all my USB handlings. CUSB is not a form class. I want to call CUSB::MyFunction on device change. My first question is, what should I send as HANDLE to RegisterDeviceNotification ? When using TForm classes, which contain a HANDLE, they just send this->Handle; But I do not have such a HANDLE. Can I use just "this" as a HANDLE?
DeviceNotificationHandle = RegisterDeviceNotification (this, &DevBroadcastDeviceInterfa ce, DEVICE_NOTIFY_WINDOW_HANDL E);
The other question is: how do I set CUSB::MyFunction to called when a WM_DEVICECHANGE message occurs?
Regards
Eimund Smestad
I'm trying to use the function RegisterDeviceNotification
I have made my own class, CUSB, which contain all my USB handlings. CUSB is not a form class. I want to call CUSB::MyFunction on device change. My first question is, what should I send as HANDLE to RegisterDeviceNotification
DeviceNotificationHandle = RegisterDeviceNotification
The other question is: how do I set CUSB::MyFunction to called when a WM_DEVICECHANGE message occurs?
Regards
Eimund Smestad
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Well, your form does for sure have a window handle, ant that should clear everything up...
ASKER
CUSB is not of TForm class, and I don't want it to be either!
My question is if this is possible for a regular class?
Eimund Smestad
My question is if this is possible for a regular class?
Eimund Smestad
But you need some form to process the messages, since callback functions are not allowed for that notification...
ASKER
Yes it is what I realized, I thought initialy that it was a callback function. But since it is not, then my current solution is more appealing to me. I have a function which I can check for a valide respons, the only drawback is that I need a timer to pull this function.
But thank you very much for the clarification.
Eimund Smestad
But thank you very much for the clarification.
Eimund Smestad
ASKER
Is there a way to use the HANDLE to my USB device to check if it is still attached or detached?
Eimnund Smestad