Maxim
Tue Jan 13 18:19:22 CST 2004
Also note that if a service handle (not window handle) is used for
notifications, then the arrived interface name is always Unicode and is never
ANSI. Just use CreateFileW with it.
--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com
"Jim Cavalaris [MS]" <jamesca@online.microsoft.com> wrote in message
news:40034779$1@news.microsoft.com...
> from:
>
http://groups.google.com/groups?selm=3ff5d26f%241%40news.microsoft.com
>
> to register for notification of query-removal, etc. events for a
> device that you have a handle to, also use RegisterDeviceNotification,
> but with a DBT_DEVTYP_HANDLE type NotificationFilter. specify the
> handle to the device in the dbch_handle member of the
> DEV_BROADCAST_HANDLE structure.
>
> RegisterDeviceNotification:
>
>
http://msdn.microsoft.com/library/en-us/devio/base/registerdevicenotification.asp
>
> both device interface and target device change notifications are
> sent as WM_DEVICECHANGE mesgs, and both types use some of the
> same DBT_* event types, so it is important to know which type
> of event you have received.
>
> Processing a Request to Remove a Device:
>
>
http://msdn.microsoft.com/library/en-us/devio/base/processing_a_request_to_remove_a_device.asp
>
> also...
>
> when a device is query-removed, user-mode applications registered
> for DBT_DEVTYP_HANDLE notification using a handle to that device
> may receive DBT_DEVICEQUERYREMOVE notification. this happens
> before the driver stack is sent IRP_MN_QUERY_REMOVE_DEVICE.
>
> if an application vetoes the query-removal notification, the
> driver stack will not receive the query-remove irp. open handles
> to the device being query-removed will also cause the removal to
> fail.
>
> any applications that receive the DBT_DEVICEQUERYREMOVE notification
> will receive a corresponding DBT_DEVICEQUERYREMOVEFAILED in response
> to the failure.
>
> if the query-removal attempt is successful, registered applications
> will also receive DBT_DEVICEREMOVEPENDING notification.
>
> DBT_DEVICEREMOVEPENDING notification is sent during the removal
> process, after all query-removal notifications have suceeded
> (to user-mode and kernel-mode components), and the driver stack
> has suceeded the query-remove irp.
>
> after the removal has completed, applications registered for
> DBT_DEVTYP_HANDLE type notification on the device will receive
> DBT_DEVICEREMOVECOMPLETE notification.
>
> * note that DBT_DEVICEREMOVECOMPLETE is used for _both_
> DBT_DEVTYP_HANDLE and DBT_DEVTYP_DEVICEINTERFACE
> type device event notifications, so it is important to
> always check the dbch_devicetype field of the
> DEV_BROADCAST_HEADER header part of the corresponding
> structure to know what type of notification you are
> receiving.
>
> the DBT_DEVICEREMOVECOMPLETE received for a DBT_DEVTYP_HANDLE
> registration is in addition to any DBT_DEVICEREMOVECOMPLETE
> notifications that an application may receive for
> a DBT_DEVTYP_DEVICEINTERFACE registration for any device
> interfaces that are disabled for the device during the
> removal process.
>
> if a surprise-removal occurs, applications will not receive
> any DBT_DEVICEQUERYREMOVE or DBT_DEVICEREMOVEPENDING notifications
> for their DBT_DEVTYP_HANDLE registrations on that device.
> they will only receive DBT_DEVICEREMOVECOMPLETE notification.
>
> upon receiveing the DBT_DEVTYP_HANDLE type of DBT_DEVICEREMOVECOMPLETE
> notification, an application should immediately unregister the
> corresponding HDEVNOTIFY handle by calling UnregisterDeviceNotification
> (or sooner, if further notification is not required).
>
> if any new handle is opened to the device, it should be registered
> for DBT_DEVTYP_HANDLE type notification separately.
>
> hope this helps,
> jim.
>
> --
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
> "Raj" <r_konjeti@mailcity.com> wrote in message
> news:8509fde8.0401121311.546aa620@posting.google.com...
> > I get query_remove_device notification in my 1394 device driver. But I
> > am not getting it in my application. I get DEVICE_REMOVE_COMPLETE and
> > add_device, both to my driver and application.
> >
> > This is how I registered for 1394 device change notifications in
> > Application code.
> >
> > devBroadcastInterface.dbcc_size =
> > sizeof(DEV_BROADCAST_DEVICEINTERFACE);
> > devBroadcastInterface.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
> > devBroadcastInterface.dbcc_name[0] = 0;
> >
> > devBroadcastInterface.dbcc_classguid = t1394DiagGUID;
> >
> > hNotify = RegisterDeviceNotification( SharedData->g_hWnd,
> > &devBroadcastInterface,
> > DEVICE_NOTIFY_WINDOW_HANDLE );
> >
> > In my driver, I am simply passing the Irp down the stack for Query
> > with success in status. Should I do something here.
> >
> > 1. I want to receive notification of 1394 devices to all devices in
> > the 1394 network.
> >
> > 2. How can I get a notification in App *before* driver receives
> > QUERY/IRP_MN_REMOVE_DEVICE.
> >
> > 3. I also want to know if how I can get DBT_DEVICEREMOVEPENDING in
> > application so that application do some clearing before device is
> > removed, if possible. Will this notification come even for
> > surprise_remove.
> >
> > Thanks.
>
>