Safely remove a USB drive using the Win32 API? Safely remove a USB drive using the Win32 API? windows windows

Safely remove a USB drive using the Win32 API?


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


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 is a technet article about removable storage media. Look for DismountNtmsMedia.