Platform SDK: Hardware |
The RegisterDeviceNotification function specifies the device or type of device for which a window will receive notifications.
HDEVNOTIFY RegisterDeviceNotification( HANDLE hRecipient, LPVOID NotificationFilter, DWORD Flags );
Services can specify either a window handle or service status handle.
Type | Description |
---|---|
DEVICE_NOTIFY_WINDOW_HANDLE | The hRecipient parameter is a window handle. |
DEVICE_NOTIFY_SERVICE_HANDLE | The hRecipient parameter is a service status handle. |
If the function succeeds, the return value is a device notification handle.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.
Applications send event notifications using the BroadcastSystemMessage function. Any application with a top-level window can receive basic notifications by processing the WM_DEVICECHANGE message. Applications can use the RegisterDeviceNotification function to register to receive device notifications.
Services can use the RegisterDeviceNotification function to register to receive device notifications. If a service specifies a window handle in the hRecipient parameter, the notifications are sent to the window procedure. If hRecipient is a service status handle, the notifications are sent to the service control handler. For more information about the service control handler, see HandlerEx.
Device notification handles returned by RegisterDeviceNotification must be closed by calling the UnregisterDeviceNotification function when they are no longer needed.
Windows NT/2000: Requires Windows 2000.
Windows 95/98: Requires Windows 98.
Header: Declared in Winuser.h; include Windows.h.
Library: Use User32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows 2000.
Device Management Overview, Device Management Functions, BroadcastSystemMessage, DEV_BROADCAST_HDR, HandlerEx, UnregisterDeviceNotification, WM_DEVICECHANGE