Author Topic: [RegisterDeviceNotification] Handle connection/disconnection of USB HID devices  (Read 12557 times)

ModularMix

  • Member
  • ***
  • Posts: 4
Hello,

I'm currently trying to handle USB HID device notifications.
So I'm using RegisterDeviceNotifications() method, which comes from "usbhidio_vc6" sample application. But this sample is a MFC application, and I want to detect HID device notifications in a Win32 application.

According to MSDN documentation for RegisterDeviceNotification method, notification filter can be either a window or a service status filter. In the MFC application, the window filter is used. So is it possible to use the service status filter for a Win32 application ?

Thanks for your answer.

Best regards,
Aymeric.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
I don't have example code, but a web search on:

RegisterDeviceNotification  service status filter

brings up some info that might help.

Jan

ModularMix

  • Member
  • ***
  • Posts: 4
Thanks Jan.

Actually, I found an interesting sample code on MSDN right here : http://msdn.microsoft.com/en-us/library/ff559882%28v=vs.85%29.aspx.
It explains very well how to process an application notification on both Win32 and MFC applications, by handling WM_DEVICECHANGE messages.

But I'm still failing to register to device notifications using RegisterDeviceNotification. The point is that this function requires a window handle to process the messages, I don't know which parameter to use for a Win32 application... By default, I've used NULL.
By checking the return of this function (HDEVNOTIFY type), the application notices me that device notification registration has failed.

Regards,
Aymeric.