网站首页  词典首页

请输入您要查询的函数:

 

术语 registerdevicenotification
释义 RegisterDeviceNotification
语法:
C++
HDEVNOTIFY WINAPI RegisterDeviceNotification(
__in HANDLE hRecipient,
__in LPVOID NotificationFilter,
__in DWORD Flags
);
RegisterDeviceNotification功能
登记册的设备或装置的一个窗口,将收到通知的类型。
参数
hRecipient [in]
句柄的窗口或服务,将获得在NotificationFilter参数中指定的设备,设备事件。同样的窗口句柄可以用来以RegisterDeviceNotification多次调用。
服务可以指定窗口句柄或服务的状态处理。
NotificationFilter [in]
A到的数据,指定装置的通知应送达类型块的指针。此块总是始于DEV_BROADCAST_HDR结构。下面的这头数据依赖于对dbch_devicetype成员的值,可以DBT_DEVTYP_DEVICEINTERFACE或DBT_DEVTYP_HANDLE。有关更多信息,请参见备注。
标志 [in]
此参数可以是下列值之一。
ValueMeaning
DEVICE_NOTIFY_WINDOW_HANDLE
0x00000000The hRecipient参数是一个窗口句柄。
DEVICE_NOTIFY_SERVICE_HANDLE
0x00000001The hRecipient参数是一个服务的状态处理。
此外,您可以指定以下值。
ValueMeaning
DEVICE_NOTIFY_ALL_INTERFACE_CLASSES
0x00000004Notifies的所有设备接口类设备接口的事件接收者。 (在dbcc_classguid成员被忽略。)
此值可用于只有dbch_devicetype成员DBT_DEVTYP_DEVICEINTERFACE。
Windows 2000中:此值不支持。
返回值
如果函数成功,返回值是一个设备的通知处理。
如果函数失败,返回值为NULL。为了获得更多错误信息,调用GetLastError。
备注
应用程序发送事件通知使用BroadcastSystemMessage功能。任何一个顶层窗口应用程序可以接收处理WM_DEVICECHANGE消息基本通知。应用程序可以使用RegisterDeviceNotification函数来注册接收设备的通知。
服务可以使用RegisterDeviceNotification函数来注册接收设备的通知。如果服务指定一个窗口句柄在hRecipient参数,通知被发送到窗口过程。如果hRecipient是一个服务的状态处理,SERVICE_CONTROL_DEVICEEVENT通知发送到服务控制处理程序。欲了解更多有关该服务控制处理信息,请参阅HandlerEx。
一定要处理即插即用尽快播放设备事件。否则,系统可能会变得没有反应。如果您的事件处理程序执行的操作可能会阻止执行(如I / O)的,最好是启动另一个线程来执行该操作异步。
通知处理设备返回RegisterDeviceNotification必须由函数调用UnregisterDeviceNotification时,不再需要关闭。
在DBT_DEVICEARRIVAL和DBT_DEVICEREMOVECOMPLETE事件自动发送到所有顶级Level的端口设备窗口。因此,没有必要要求端口RegisterDeviceNotification,函数失败如果dbch_devicetype成员DBT_DEVTYP_PORT。成交量通知我们并播放顶层窗口,因此函数失败如果dbch_devicetype是DBT_DEVTYP_VOLUME。原始设备制造商定义的设备并非直接使用该系统,因此函数失败如果dbch_devicetype是DBT_DEVTYP_OEM。
实例
有关示例,请注册为设备的通知。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinuser.h(头文件:winuser.h)
LibraryUser32.lib
DLLUser32.dll
Unicode和ANSI namesRegisterDeviceNotificationW(Unicode)和RegisterDeviceNotificationA(ANSI)的
参见
BroadcastSystemMessage
DEV_BROADCAST_HDR
设备管理功能
设备通知
HandlerEx
UnregisterDeviceNotification
WM_DEVICECHANGE
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年7月30日
==英文原文==RegisterDeviceNotification Function
Registers the device or type of device for which a window will receive notifications.
Syntax
C++
HDEVNOTIFY WINAPI RegisterDeviceNotification(
__in HANDLE hRecipient,
__in LPVOID NotificationFilter,
__in DWORD Flags
);
Parameters
hRecipient [in]
A handle to the window or service that will receive device events for the devices specified in the NotificationFilter parameter. The same window handle can be used in multiple calls to RegisterDeviceNotification.
Services can specify either a window handle or service status handle.
NotificationFilter [in]
A pointer to a block of data that specifies the type of device for which notifications should be sent. This block always begins with the DEV_BROADCAST_HDR structure. The data following this header is dependent on the value of the dbch_devicetype member, which can be DBT_DEVTYP_DEVICEINTERFACE or DBT_DEVTYP_HANDLE. For more information, see Remarks.
Flags [in]
This parameter can be one of the following values.
ValueMeaning
DEVICE_NOTIFY_WINDOW_HANDLE
0x00000000The hRecipient parameter is a window handle.
DEVICE_NOTIFY_SERVICE_HANDLE
0x00000001The hRecipient parameter is a service status handle.

In addition, you can specify the following value.
ValueMeaning
DEVICE_NOTIFY_ALL_INTERFACE_CLASSES
0x00000004Notifies the recipient of device interface events for all device interface classes. (The dbcc_classguid member is ignored.)
This value can be used only if the dbch_devicetype member is DBT_DEVTYP_DEVICEINTERFACE.
Windows 2000: This value is not supported.

Return Value
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 .
Remarks
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, SERVICE_CONTROL_DEVICEEVENT notifications are sent to the service control handler. For more information about the service control handler, see HandlerEx .
Be sure to handle Plug and Play device events as quickly as possible. Otherwise, the system may become unresponsive. If your event handler is to perform an operation that may block execution (such as I/O), it is best to start another thread to perform the operation asynchronously.
Device notification handles returned by RegisterDeviceNotification must be closed by calling the UnregisterDeviceNotification function when they are no longer needed.
The DBT_DEVICEARRIVAL and DBT_DEVICEREMOVECOMPLETE events are automatically broadcast to all top-level windows for port devices. Therefore, it is not necessary to call RegisterDeviceNotification for ports, and the function fails if the dbch_devicetype member is DBT_DEVTYP_PORT. Volume notifications are also broadcast to top-level windows, so the function fails if dbch_devicetype is DBT_DEVTYP_VOLUME. OEM-defined devices are not used directly by the system, so the function fails if dbch_devicetype is DBT_DEVTYP_OEM.
Examples
For an example, see Registering for Device Notification .
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinuser.h (include Windows.h)
LibraryUser32.lib
DLLUser32.dll
Unicode and ANSI namesRegisterDeviceNotificationW (Unicode) and RegisterDeviceNotificationA (ANSI)
See Also
BroadcastSystemMessage
DEV_BROADCAST_HDR
Device Management Functions
Device Notifications
HandlerEx
UnregisterDeviceNotification
WM_DEVICECHANGE
Send comments about this topic to Microsoft
Build date: 7/30/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa363431(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 11:22:41