PC Review


Reply
Thread Tools Rate Thread

Detecting a USB drive arrival/removal, where the drive has beenunmounted (drive letter removed)

 
 
GeneM
Guest
Posts: n/a
 
      18th Dec 2008
Hi all,

I'm creating an application tht detects when USB drives are inserted
and removed. I've overridden the WndProc method in a hidden form to
trap the WM_DEVICECHANGE messages and then inspect the WParam for
DBT_DEVICEARRIVAL, DBT_DEVICEQUERYREMOVE, and DBT_DEVICEREMOVECOMPLETE
values.

However if the Drive leter is removed for a drive, the WM_DEVICECHANGE
message is pumped but only with the DBT_DEVNODES_CHANGED parameter,
which isn't unique or a reliable way to indentify this event.


Can anyone comment or make a suggestion please?


e.g.-
if (m.Msg == WM_DEVICECHANGE) {

switch (m.WParam.ToInt32()) {

case DBT_DEVICEARRIVAL:
...
break;

case DBT_DEVICEQUERYREMOVE:
...
break;

case DBT_DEVICEREMOVECOMPLETE:
...
break;
}
}
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Detecting CD drive letter in C# yellowblueyellow@gmail.com Microsoft C# .NET 4 12th Jul 2007 07:05 PM
Drive letter assignment, new drive swapped, reformat old drive =?Utf-8?B?SmltTGV3YW5kb3dza2k=?= Windows XP Performance 0 10th Mar 2006 07:07 PM
Installed Jump Drive tries to share drive letter with Mapped Drive =?Utf-8?B?RkdhcnZpbg==?= Windows XP General 2 14th Mar 2005 06:24 PM
Detecting the drive letter of a user's CD Charles Jordan Microsoft Excel Programming 4 24th Sep 2004 06:08 AM
Can't unhide drive. Drive letter conflict, drive disappeared. edm Windows XP Help 0 2nd Jul 2004 08:44 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:48 AM.