Article View: borland.public.cppbuilder.nativeapi
Article #4450Re: Question about WM_DEVICECHANGE
From: Remy Lebeau (TeamB)
Date: Wed, 25 Jan 2006 19:23
Date: Wed, 25 Jan 2006 19:23
57 lines
2811 bytes
2811 bytes
"Kris" <x.y@xyz.xx> wrote in message
news:3qbft19f0602l0f1m44t2uhiuio593trh1@4ax.com...
> Such operations are accompanied by following message :
> WM_DEVICECHANGE : DBT_DEVNODES_CHANGED
That only works on Win2000 and later.
I would suggest using DBT_DEVICEARRIVAL and DBT_DEVICEREMOVECOMPLETE
instead. They tell you the specific device that was added/removed, and they
are available on all OS versions.
> Any ideas on how to accomplish this ?
According to the documentation for DBT_DEVNODES_CHANGED:
"There is no additional information about which device has been added to
or removed from the system. Applications that require more information
should register for device notification."
Look at the RegisterDeviceNotification() function.
> Should I just wait a little bit longer, e.g. treat all
DBT_DEVNODES_CHANGED
> in a 2 second time-span as one DBT_DEVNODES_CHANGED message
> that will then trigger a new device scan ?
No.
> I was also looking at using DBT_DEVICEARRIVAL and
> DBT_DEVICEREMOVECOMPLETE. Unfortunately,
> these events are also sent when I remove or insert a CD in the drive.
So? You can filter those out before deciding to scan your devices. Or,
don't even scan at all. Use the details inside those notifications to
add/remove just those specific items to/from your list instead of refreshing
the entire list as a whole, since notifications are sent on a per-device
basis to begin with.
> Connect device :
> DBT_DEVNODES_CHANGED
> DBT_DEVNODES_CHANGED
> DBT_DEVICEREMOVECOMPLETE
>
> Remove device :
> DBT_DEVNODES_CHANGED
> DBT_DEVNODES_CHANGED
> DBT_DEVNODES_CHANGED
> DBT_DEVICEARRIVAL
> DBT_DEVNODES_CHANGED
Are you sure you have that right? You get a removal notification when you
connect a device, and an arrival notification when you remove it?
Gambit
Technical Details
Message-ID:
<43d7cf9f$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news4.google.com!news.glorb.com!proxad.net!proxad.net!194.117.148.138.MISMATCH!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<3qbft19f0602l0f1m44t2uhiuio593trh1@4ax.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,72e517fafc72a733 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <3qbft19f0602l0f1m44t2uhiuio593trh1@4ax.com> Subject: Re: Question about WM_DEVICECHANGE Date: Wed, 25 Jan 2006 11:23:43 -0800 Lines: 59 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 68.69.17.41 Message-ID: <43d7cf9f$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1138216863 68.69.17.41 (25 Jan 2006 11:21:03 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news4.google.com!news.glorb.com!proxad.net!proxad.net!194.117.148.138.MISMATCH!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail