I have a USB MSC device for which I've written a desktop application that can
eject the device similar to using the Unplug or Eject Hardware utility.

Currently, my code calls CM_Request_Device_Eject to cleanly eject the
device. However, the device does not sense that it has been disconnected.

If I call DeviceIoControl with IOCTL_STORAGE_EJECT_MEDIA, the device does
sense that it was ejected but I also get the Unsafe Removal of Hardware
dialog under Windows 2000.

Is there a correct method to cleanly stop the device and have it sense that
it has been disconnected under Windows 2000 and XP (no support needed for
older OSs).

Thanks.
Glenn

Re: Programmatic USB device eject by Robert

Robert
Fri Oct 14 23:48:48 CDT 2005

gpeffers wrote:

> Currently, my code calls CM_Request_Device_Eject to cleanly eject the
> device. However, the device does not sense that it has been disconnected.

If you have a custom driver then it may be buggy.
If not you may call this function on the wrong DevNode.

Re: Programmatic USB device eject by Maxim

Maxim
Tue Oct 18 18:31:34 CDT 2005

> If I call DeviceIoControl with IOCTL_STORAGE_EJECT_MEDIA, the device

This is not a device eject. This is a CD or DVD disc eject. Device eject is
different.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com