From: Timothy Jewett on
I am trying to wite a service that will detect when a USB storage device is
inserted to display a warning message. I have written the service that
detects USB device insertions but I get my message when any USB device is
inserted. I would like to narrow that down to just storage devices, thumb
drives and external hard disks...

Can someone point me in the correct direction as to how I can narrow that
down ?

Thanks,
--
Timothy Jewett
Jewettware(a)online.nospam
From: Pavel A. on
"Timothy Jewett" <jewettware(a)online.nospam> wrote in message
news:AA0B3A4C-4DBB-4C96-A1C3-2AF82B62A2F2(a)microsoft.com...
> I am trying to wite a service that will detect when a USB storage device
> is
> inserted to display a warning message. I have written the service that
> detects USB device insertions but I get my message when any USB device is
> inserted. I would like to narrow that down to just storage devices, thumb
> drives and external hard disks...
>
> Can someone point me in the correct direction as to how I can narrow that
> down ?
>
> Thanks,
> --
> Timothy Jewett
> Jewettware(a)online.nospam

When you register for hardware change notification, maybe you specify a
wrong id in the filter.
You need DBT_DEVTYP_VOLUME, or DBT_DEVTYP_DEVICEINTERFACE
with class = DiskDrive or Volume.

-- pa


From: Microsoft Corporation on

//Add these code to the initialization part

DEV_BROADCAST_HDR NotificationFilter;
NotificationFilter.dbch_size = sizeof(DEV_BROADCAST_HDR);
NotificationFilter.dbch_devicetype = DBT_DEVTYP_VOLUME;

hDevNotify = RegisterDeviceNotification(hMainWnd, &NotificationFilter,
DEVICE_NOTIFY_WINDOW_HANDLE);

///<\Custom Initialization Code>

//Application_Run(), can also be a message loop.

UnregisterDeviceNotification(hDevNotify);

//So that you can get notifications only when Mass Storage Device is
inserted.


----- Original Message -----
From: "Timothy Jewett" <jewettware(a)online.nospam>
Newsgroups: microsoft.public.win32.programmer.kernel
Sent: Friday, May 28, 2010 04:45
Subject: USB Storage Device Detetcion


>I am trying to wite a service that will detect when a USB storage device is
> inserted to display a warning message. I have written the service that
> detects USB device insertions but I get my message when any USB device is
> inserted. I would like to narrow that down to just storage devices, thumb
> drives and external hard disks...
>
> Can someone point me in the correct direction as to how I can narrow that
> down ?
>
> Thanks,
> --
> Timothy Jewett
> Jewettware(a)online.nospam



From: Timothy Jewett on
I tried your example and I get a 0x42A returned from
RegisterDeviceNotification(), any idea ?
--
Timothy Jewett
Jewettware(a)online.nospam


"Microsoft Corporation" wrote:

> //Add these code to the initialization part
>
> DEV_BROADCAST_HDR NotificationFilter;
> NotificationFilter.dbch_size = sizeof(DEV_BROADCAST_HDR);
> NotificationFilter.dbch_devicetype = DBT_DEVTYP_VOLUME;
>
> hDevNotify = RegisterDeviceNotification(hMainWnd, &NotificationFilter,
> DEVICE_NOTIFY_WINDOW_HANDLE);
>
> ///<\Custom Initialization Code>
>
> //Application_Run(), can also be a message loop.
>
> UnregisterDeviceNotification(hDevNotify);
>
> //So that you can get notifications only when Mass Storage Device is
> inserted.
>
>
> ----- Original Message -----
> From: "Timothy Jewett" <jewettware(a)online.nospam>
> Newsgroups: microsoft.public.win32.programmer.kernel
> Sent: Friday, May 28, 2010 04:45
> Subject: USB Storage Device Detetcion
>
>
> >I am trying to wite a service that will detect when a USB storage device is
> > inserted to display a warning message. I have written the service that
> > detects USB device insertions but I get my message when any USB device is
> > inserted. I would like to narrow that down to just storage devices, thumb
> > drives and external hard disks...
> >
> > Can someone point me in the correct direction as to how I can narrow that
> > down ?
> >
> > Thanks,
> > --
> > Timothy Jewett
> > Jewettware(a)online.nospam
>
>
>
> .
>
From: Timothy Jewett on
I did figure out the 42a was because you cannot register for a broadcast
volume. I do receive the broadcast volume on thumb drives but do not receive
anything for CD/DVD media insertion. Is ther some other method to receive the
change for media on cd/dvd devices ?
--
Timothy Jewett
Jewettware(a)online.nospam


"Microsoft Corporation" wrote:

> //Add these code to the initialization part
>
> DEV_BROADCAST_HDR NotificationFilter;
> NotificationFilter.dbch_size = sizeof(DEV_BROADCAST_HDR);
> NotificationFilter.dbch_devicetype = DBT_DEVTYP_VOLUME;
>
> hDevNotify = RegisterDeviceNotification(hMainWnd, &NotificationFilter,
> DEVICE_NOTIFY_WINDOW_HANDLE);
>
> ///<\Custom Initialization Code>
>
> //Application_Run(), can also be a message loop.
>
> UnregisterDeviceNotification(hDevNotify);
>
> //So that you can get notifications only when Mass Storage Device is
> inserted.
>
>
> ----- Original Message -----
> From: "Timothy Jewett" <jewettware(a)online.nospam>
> Newsgroups: microsoft.public.win32.programmer.kernel
> Sent: Friday, May 28, 2010 04:45
> Subject: USB Storage Device Detetcion
>
>
> >I am trying to wite a service that will detect when a USB storage device is
> > inserted to display a warning message. I have written the service that
> > detects USB device insertions but I get my message when any USB device is
> > inserted. I would like to narrow that down to just storage devices, thumb
> > drives and external hard disks...
> >
> > Can someone point me in the correct direction as to how I can narrow that
> > down ?
> >
> > Thanks,
> > --
> > Timothy Jewett
> > Jewettware(a)online.nospam
>
>
>
> .
>