So, I recently got a new toy: a nifty 32 MB PenDrive (www.pendrive.com), which I'm using to carry my work files about to and from home/laptop/work/etc. It's a great system, and saves me a lot of hassle. The only issue I have is that I can't stand the current means available for safely ejecting the device, which uses that silly Unplug/Eject hardware wizard - too many mouse clicks, too troublesome when I have to run. So I'm looking for a way to automate it, preferably without screenscraping.
So far I've stumbled onto this li'l article all about Ejecting Removable Media in Windows NT-2000-XP (note that this discovery was, naturally, subsequent to numerous hours plugging away at DeviceIoControl unsuccessfully in Delphi). A quick recompile later, and despite the VC++'s program's assurances to the contrary (voiced in the forms of "Media in Drive E has been ejected safely."
and "Media in Drive E can be safely removed."), it was clear that while the program could succeed in unmounting the device (gee, thanks, like mountvol.exe couldn't do that already
), it was incapable of stopping it to the satisfaction of Win2K's Unplug/Eject icon, which was quite convinced I was committing a grave violation of the hapless device each time it was so unceremoniously removed.
I would love to simply brush off the warnings, if someone could assure me that it was indeed harmless overreacting on Windows' part, but the cautious left-brain side is in a tizzy. Have you ever seen a brain in a tizzy? Not pretty.
So, if anyone can suggest some good linkage (or even better, Delphi code fragments
) on how to handle truly unloading the device, I will be eternally grateful, or at least until I forget about this. Thanks muchly.
Since so few posts in this forum seem to have images I thought I would liven it up with a nice pic of the toy as well:
So far I've stumbled onto this li'l article all about Ejecting Removable Media in Windows NT-2000-XP (note that this discovery was, naturally, subsequent to numerous hours plugging away at DeviceIoControl unsuccessfully in Delphi). A quick recompile later, and despite the VC++'s program's assurances to the contrary (voiced in the forms of "Media in Drive E has been ejected safely."
and "Media in Drive E can be safely removed."), it was clear that while the program could succeed in unmounting the device (gee, thanks, like mountvol.exe couldn't do that already
I would love to simply brush off the warnings, if someone could assure me that it was indeed harmless overreacting on Windows' part, but the cautious left-brain side is in a tizzy. Have you ever seen a brain in a tizzy? Not pretty.
So, if anyone can suggest some good linkage (or even better, Delphi code fragments
Since so few posts in this forum seem to have images I thought I would liven it up with a nice pic of the toy as well: