Safely remove a USB drive using the Win32 API?
It looks like Sync lets you specify -e to eject removable drives. While not a win32 API, you could probably just call sync -e [drive_letter]
from your makefile.
Here's a solution in Delphi, that I've modified and put into a service for use in a very large enterprise. Go to: link text
Look for "scapi (Setup & Config Manager API)", and download it. There will be a demo program called USBView that will get you on your way. If you have Delphi, this also includes a TUSBDeviceTree component that you can use to gather information about a USB device when.
Regards
You can use the CM_Request_Device_Eject() function as well as some other possibilities. Consult the following projects and articles:
DevEject: Straightforward. http://www.withopf.com/tools/deveject/
A useful CodeProject article: http://www.codeproject.com/KB/system/RemoveDriveByLetter.aspx
Here is a technet article about removable storage media. Look for DismountNtmsMedia
.