Prev: Writing File System Driver & Creating Virtual Disk Drive in Windows XP [Question by a Novice]
Next: Taking over a session..
From: Gary Chanson on 12 Jan 2007 07:10 "Uwe Sieber" <mail(a)uwe-sieber.de> wrote in message news:50otqgF1gfualU3(a)mid.individual.net... > > With 'SdCard' you mean a PCI attached SD card reader? Then > you have luck to get it back by means of "Scan for hardware > changes". It would not work that way with an internal USB > card reader. > Here the right way is to eject the media using > IOCTL_STORAGE_EJECT_MEDIA. That ejects media, not devices. A USB memory stick is a device, not media. A floppy or a CD is media. -- - Gary Chanson (Windows SDK MVP) - Abolish Public Schools
From: Jeff Henkels on 12 Jan 2007 07:57 "Gary Chanson" <gchanson(a)No.Spam.mvps.org> wrote in message news:ub56ZMkNHHA.4912(a)TK2MSFTNGP02.phx.gbl... > > "Uwe Sieber" <mail(a)uwe-sieber.de> wrote in message > news:50otqgF1gfualU3(a)mid.individual.net... >> >> With 'SdCard' you mean a PCI attached SD card reader? Then >> you have luck to get it back by means of "Scan for hardware >> changes". It would not work that way with an internal USB >> card reader. >> Here the right way is to eject the media using >> IOCTL_STORAGE_EJECT_MEDIA. > > That ejects media, not devices. A USB memory stick is a device, not > media. A floppy or a CD is media. That's technically true, but for a USB stick (at least one with only one partition -- let's ignore U3 type devices) the media and the device are effectively the same. If you do an IOCTL_STORAGE_EJECT_MEDIA on the USB stick, the drive associated with that stick is no longer accessible. Assuming a successful completion of the ioctl, the device should be in a quiescent state, such that it can be removed from the bus. I'd expect a IRP_MN_SURPRISE_REMOVAL event, but because the device is quiescent, the handling of that event should be trivial.
From: Uwe Sieber on 12 Jan 2007 11:08 Gary Chanson wrote: > "Uwe Sieber" <mail(a)uwe-sieber.de> wrote in message > news:50otqgF1gfualU3(a)mid.individual.net... >> With 'SdCard' you mean a PCI attached SD card reader? Then >> you have luck to get it back by means of "Scan for hardware >> changes". It would not work that way with an internal USB >> card reader. >> Here the right way is to eject the media using >> IOCTL_STORAGE_EJECT_MEDIA. > > That ejects media, not devices. A USB memory stick is a device, not > media. A floppy or a CD is media. He obviously wrote about an internal device. What sense should it make to prepare an internal device for save removal. It cannot be removed without opening the box. Uwe
From: Echo on 12 Jan 2007 22:54 Some are PCI attached, some are internal usb attached. I tried many. Some can be ejected with IOCTL_STORAGE_EJECT_MEDIA, FSCTL_DISMOUNT_VOLUME, some can't. As to current one I'm testing, it's PCI attached, and can't work with IOCTL_STORAGE_EJECT_MEDIA, FSCTL_DISMOUNT_VOLUME. I refer to MS KB article: http://support.microsoft.com/kb/165721 when using IOCTL_STORAGE_EJECT_MEDIA method. Thanks & Regards, Echo "Uwe Sieber" wrote: > > With 'SdCard' you mean a PCI attached SD card reader? Then > you have luck to get it back by means of "Scan for hardware > changes". It would not work that way with an internal USB > card reader. > Here the right way is to eject the media using > IOCTL_STORAGE_EJECT_MEDIA. > > > Uwe > > > Echo wrote: > > I tried the project, it works well with usb devices (calling > > CM_Request_Device_Eject), but has problem with fixed drive such as SdCard > > (calling CM_Query_And_Remove_SubTree). SdCard can be ejected, but can't be > > recognized after reinsertion. I have to "Scan for hardware changes" in > > Control Panel to force system to find the device. > > > > Thanks & Regards, > > Echo > > > > "Uwe Sieber" wrote: > > > >> Some are a bit hidden in too much text... > >> If you want to program it yourself, here is my demo project: > >> http://www.codeproject.com/system/RemoveDriveByLetter.asp > >> > >> > >> It uses CM_Query_And_Remove_SubTree to remove the USB device. > >> But this function requires admin previleges while > >> CM_Request_Device_Eject works without. No idea why. > >> > >> > >> Uwe > >> > >> > >> > >> > >> > >> Echo wrote: > >>> Thanks a lot! > >>> > >>> I got what I want! And many useful tools! > >>> > >>> Regards, > >>> Echo > >>> > >>> > >>> "Pavel A." wrote: > >>> > >>>> Look at http://www.uwe-sieber.de/ > >>>> > >>>> Regards, > >>>> --PA > >>>> > >>>> "Echo" wrote: > >>>>> Removable devices, such as usb devices, flashmedia card, can only be safely > >>>>> removed by clicking the icon in system tray in WinXP. But how to make it > >>>>> programmatically? > >>>>> > >>>>> I tried IOCTL_STORAGE_EJECT_MEDIA, FSCTL_DISMOUNT_VOLUME, but only have > >>>>> effect in several special cases. > >>>>> > >>>>> Any advice be appreciated! > >>>>> > >>>>> >
From: Uwe Sieber on 13 Jan 2007 09:24
What do you mean with "can't work with"? Is it one of these scrap devices with GetDriveType returns DRIVE_UNKNOWN for? Uwe Echo wrote: > Some are PCI attached, some are internal usb attached. I tried many. Some can > be ejected with IOCTL_STORAGE_EJECT_MEDIA, FSCTL_DISMOUNT_VOLUME, some > can't. As to current one I'm testing, it's PCI attached, and can't work with > IOCTL_STORAGE_EJECT_MEDIA, FSCTL_DISMOUNT_VOLUME. > > I refer to MS KB article: http://support.microsoft.com/kb/165721 when using > IOCTL_STORAGE_EJECT_MEDIA method. > > Thanks & Regards, > Echo > > "Uwe Sieber" wrote: > >> With 'SdCard' you mean a PCI attached SD card reader? Then >> you have luck to get it back by means of "Scan for hardware >> changes". It would not work that way with an internal USB >> card reader. >> Here the right way is to eject the media using >> IOCTL_STORAGE_EJECT_MEDIA. >> >> >> Uwe >> >> >> Echo wrote: >>> I tried the project, it works well with usb devices (calling >>> CM_Request_Device_Eject), but has problem with fixed drive such as SdCard >>> (calling CM_Query_And_Remove_SubTree). SdCard can be ejected, but can't be >>> recognized after reinsertion. I have to "Scan for hardware changes" in >>> Control Panel to force system to find the device. >>> >>> Thanks & Regards, >>> Echo >>> >>> "Uwe Sieber" wrote: >>> >>>> Some are a bit hidden in too much text... >>>> If you want to program it yourself, here is my demo project: >>>> http://www.codeproject.com/system/RemoveDriveByLetter.asp >>>> >>>> >>>> It uses CM_Query_And_Remove_SubTree to remove the USB device. >>>> But this function requires admin previleges while >>>> CM_Request_Device_Eject works without. No idea why. >>>> >>>> >>>> Uwe >>>> >>>> >>>> >>>> >>>> >>>> Echo wrote: >>>>> Thanks a lot! >>>>> >>>>> I got what I want! And many useful tools! >>>>> >>>>> Regards, >>>>> Echo >>>>> >>>>> >>>>> "Pavel A." wrote: >>>>> >>>>>> Look at http://www.uwe-sieber.de/ >>>>>> >>>>>> Regards, >>>>>> --PA >>>>>> >>>>>> "Echo" wrote: >>>>>>> Removable devices, such as usb devices, flashmedia card, can only be safely >>>>>>> removed by clicking the icon in system tray in WinXP. But how to make it >>>>>>> programmatically? >>>>>>> >>>>>>> I tried IOCTL_STORAGE_EJECT_MEDIA, FSCTL_DISMOUNT_VOLUME, but only have >>>>>>> effect in several special cases. >>>>>>> >>>>>>> Any advice be appreciated! >>>>>>> >>>>>>> |