View Full Version : Reading/Writing data from/to usb device

6th March 2006, 10:29
Hi there !

I need to detect when an usb key is plugged and I also need to access (read/write) data stored onto that key.

In my opinion the main problem is to auto detect the usb device ... then I imagine it is easy to read/write data (as it is on a hard drive).

Could someone tell me how to detect the usb key ?

Thanks in advance.

6th March 2006, 11:27
Two ways.

Proper one:
You should plug into some platform dependent routines which notify for such events. Windows probably has some api for this, but it's out of scope of this forum, so you'd have to find experts on this topic.

Monitor the list of drives yourself and act when something is added to the list. Just remember it can be some other device (cdrom?), not only a usb drive.

6th March 2006, 14:08
Seems that you mainly concern on a Windows specific solution. You could take a look at:
How to match between physical usb device and its drive letter? (http://groups.google.com/group/microsoft.public.development.device.drivers/browse_thread/thread/47322a079ae87adc/09e0c366cacda5c0?q=%22How%2Bto%2Bmatch%2Bbetween%2 Bphysical%2Busb%2Bdevice%2Band%2Bits%2Bdrive%2Blet ter%22&_done=%2Fgroups%3Fas_q%3D%22How%2Bto%2Bmatch%2Bbet ween%2Bphysical%2Busb%2Bdevice%2Band%2Bits%2Bdrive %2Bletter%22%26safe%3Dimages%26lr%3D%26hl%3Den%26&_doneTitle=Back%2Bto%2BSearch&&d#09e0c366cacda5c0) and The Mass Storage Page (http://www.lvr.com/mass_storage.htm). Wysota's #2 is easier ;)