🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #3335

Re: Detecting media insertion/removal

#3335
From: Mike Wynne
Date: Tue, 27 Jun 2006 21:59
30 lines
2334 bytes
"poojo hackma" wrote...
> Just a thought:  Maybe you could store a list of devices that are on the 
> system, then whenever you receive a WM_DEVICECHANGE message, look to see 
> what is not already in your list (inserts) or what in your list is no 
> longer available (removed).

Unfortunately that wouldn't work - to give you an example:

Someone plugs a USB card reader into their PC, resulting in 4 new drives 
appearing and a whole load of WM_DEVICECHANGE messages arriving at my 
application.  My application detects the new drives, but because there is no 
media inserted in any of the reader slots, doesn't do anything.

Next, a Compact Flash card is inserted into the reader.  This is what I need 
to detect but I get no messages from Windows :(

At this point my application should be processing what's on the card, but 
because it doesn't know a card has been inserted, does nothing...

After processing, the user removes the card.  Again I'm hoping to get a 
WM_DEVICECHANGE telling me the card has been removed but nothing arrives.

Finally the user removes the card reader from the PC.  This does trigger the 
message and my application detects the 4 drives disappearing.

My current solution is to put a button on my form saying something like 
"Rescan Drives", but it would be nice if it would do it automatically.

MikeW
Technical Details
Message-ID: <44a1aa53@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <44a17fbc$1@newsgroups.borland.com> <44a1a4e8$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,e15854a90a45465d
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Mike Wynne" <mikeywyn@hotmail.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <44a17fbc$1@newsgroups.borland.com> <44a1a4e8$1@newsgroups.borland.com>
Subject: Re: Detecting media insertion/removal
Date: Tue, 27 Jun 2006 22:59:48 +0100
Lines: 32
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 62.188.49.47
Message-ID: <44a1aa53@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1151445587 62.188.49.47 (27 Jun 2006 14:59:47 -0700)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail