Ports and Interfaces > USB

[RegisterDeviceNotification] Handle connection/disconnection of USB HID devices

(1/1)

ModularMix:
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:
I don't have example code, but a web search on:

RegisterDeviceNotification  service status filter

brings up some info that might help.

Jan

ModularMix:
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.

Jan Axelson:
Maybe this will help:

http://www.ms-news.net/f3603/service-registerdevicenotification-with-dev_broadcast_volume-fai-2093874.html

Jan

Navigation

[0] Message Index

Go to full version