[python-win32] Eject a Removable USB drive

Rickey, Kyle W Kyle.Rickey at bakerhughes.com
Mon Mar 2 15:42:33 CET 2009


Hello everyone,

I would like to be able to eject a usb drive based on drive letter. I've
done a bit of googling and came across the CM_Request_Device_Eject
function on MSDN (http://msdn.microsoft.com/en-us/library/ms790831.aspx)

However, I am not quite sure how to supply the necessary parameter to
the function (dnDevInst).  Does it have anything to do with:

win32file.GetVolumeNameForVolumeMountPoint("F:\\")

I'm kind of thinking that I have to get some handle to my removable
drive and then go up the device tree using CM_Get_Parent
(http://msdn.microsoft.com/en-us/library/ms791198.aspx) and then call
CM_Request_Device_Eject on the appropriate node.

I am on the right track with this? Any help would be greatly
appreciated.

-Kyle Rickey



More information about the python-win32 mailing list