Link to home
Start Free TrialLog in
Avatar of Ed Covney
Ed CovneyFlag for United States of America

asked on

Drivecombobox (Delphi), what's the proper way to test if removeable media is present

What's the proper way to test whether removeable media is inserted? Whether it's ready for writing (formatted)? Empty floppy drives and memory card readers are causing problems.

Thanks, Ed
Avatar of aflarin
aflarin

you should handle the WM_DEVICECHANGE message to rebuild list of drives.

Also you can use TJvDriveCombo from JVCL: http://jvcl.delphi-jedi.org/ 
SOLUTION
Avatar of aflarin
aflarin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ed Covney

ASKER

@Aflarin:

I may not have made myself clear.  On start-up, I need to check removable drives for a specific file. If the removable drive is a flash drive, there's is no problem - windows doesn't give it a drive letter assignment until its installed. If its a floppy or memory card drive, windows has assigned it a drive letters, whether media exists in the drive or not. So if I check A: drive and there's no floppy inserted, I get an error which asks to [Abort, Retry, or Cancel]. Want I need is a way to determine if A: has a floppy in it before stating the test.

Here's a specific example. A user has an empty floppy drive A:\,  C:\ & D:\ local hard drives, E:, F;, G: are empty memory card reader drives, H: is a USB flash drive (which hosts the file I'm looking for), and I: and J: are 2 more empty memory card drives. So the question is upon start-up, how can I be determine which removable drives realy exist?

Thanks

Ed  
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@flexiwebsw:
Your "if DiskSize(Ord(Drive) - $40) = -1 then"  was like magic !! - THANK YOU.

@aflarin
I know at some point in the future, if I don't find the file, I'll ask the user to insert the flash drive. In the mean time, I'll play with your code as I insert and remove flash drives.  Thanks

Thankyou, it was taken from a script i developed a while ago, it was to tell the user the type of drive, e.g removable, network, cd-rom or fixed, and others. but i got errors when it searched through drives that had letters but no disks. this piece of code has saved my life a few times.