I know there has been discussion on the list and forums before about how to eject drives under windows. This has been something I have wanted for a while and decided to spend a little time trying to figure it out. I though I should post my results here so they would make it into the archives.
Quite a process but I now have a module that will eject a drive that Windows considers is removable or a CD-rom (this includes USB sticks.) In the cd-rom case it will open the tray or eject the disk out of the slot. As an interesting side note I found it would not eject a mac formatted firewire disk (I use MacDrive to read it). Under more examination I found that windows also does not allow me to eject it properly from "My Computer" either. Interesting. Get Drive Type seems to return zero which is drive type unknown. All you have to do is call EjectDrive(driveletter as string) as boolean and it will open the volume, lock the volume, dismount the volume, turn off prevent removal, eject the disk an then close the handle. This process insures that drives are disposed of properly and no drives are ejected with open files. It also insures no other programs try to write to the drive during the eject process. This has been one of my first big attempts to decipher MSDN docs and use declares. Thanks to Charles Yeomans (Declaresub.com) and Aaron Ballman (http://www.aaronballman.com/programming/) for all the great resources online. I posted the project online, it is a 1 window project that sends the text in the editfield to EjectDrive. I would love it if anyone interested took a look and let me know if I have done anything incorrectly. I have tested this on XP and Vista but I would love to know if it works in Win2000. I still have alot of Win2k users. It should work according to the docs. Aaron - Please feel free to use any of this you wish in the Windows Functionality Suite. Everybody else - Please feel free to use, if you make any great improvements I would love to know. The example and module in the zip file were created with 2007r2. No plugins used. http://www.drewfindley.com/downloads/rbexamples/EjectDrive_Stuff.zip -Drew Findley _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives: <http://support.realsoftware.com/listarchives/lists.html>
