none
Forcefully Remove USB Flash Drive RRS feed

  • Question

  • There's a good sample here explaining how to programmatically stop a USB Flash drive, but very often something gets corrupted in the system or in one of the programs that uses that device and no matter what you do it won't be ejected, CM_Request_Device_Eject will return CR_REMOVE_VETOED.

    I'm curious, is there any way to forcefully remove that USB Flash Drive (well, aside from physically yanking it out of the slot), via some kernel API call? Maybe some undocumented one? And if no, is there any way to know what process is holding a reference to this device that it preventing it from being ejected?

    Saturday, May 8, 2010 8:42 PM

All replies

  • Well, I'd say no there is no way. But since this is the Windows SDK forum and the function you are asking about is part of the Windows DDK then it would be hard to give a proper answer. I would suggest you actually ask on the newsgroup for driver development. You can get to the newsgroups here.
    Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.
    Visit my (not very good) blog at
    http://c2kblog.blogspot.com/
    Monday, May 10, 2010 4:04 AM