troubleshooting Question

RegisterDeviceNotification(), how to capture the messages?

Avatar of Eimund
Eimund asked on
C++
6 Comments1 Solution2831 ViewsLast Modified:
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, &DevBroadcastDeviceInterface, DEVICE_NOTIFY_WINDOW_HANDLE);

The other question is: how do I set CUSB::MyFunction to called when a WM_DEVICECHANGE message occurs?

Regards
Eimund Smestad

ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros