Prev: Writing File System Driver & Creating Virtual Disk Drive in Windows XP [Question by a Novice]
Next: Taking over a session..
From: Echo on 13 Jan 2007 23:12 I mean, FlashMedia Card, such as SdCard, sometimes can't be ejected by IOCTL_STORAGE_EJECT_MEDIA. Echo "Uwe Sieber" wrote: > > > 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! > >>>>>>> > >>>>>>> >
From: David J. Craig on 14 Jan 2007 00:08 You have two things when you have FlashMedia. Since I wrote or helped write the drivers for a non-mass storage compliant SmartMedia & Compact Flash reader, I know it works. The eject won't really remove the media, but it will flush the dirty buffers including system areas to the media. This worked on Windows 2000. With XP there is an option to optimize media for speed and not safe removabililty so I am not sure it an speed optimized drive will properly flush. Then an open exclusive of the drive would force a flush. There is a good sequence of operations I have forgotten, but have implemented in code somewhere that will properly allow a drive to be formatted including repartitioning and then remounted with all new partitions recognized. Look at disk.sys and cleanup.sys to see what is needed. You may also want to look at fastfat.sys to see how a filesystem assists in this because it is the driver that forces the flush by the cache manager. "Echo" <Echo(a)discussions.microsoft.com> wrote in message news:5BC94204-B26D-444B-B8DC-E7207C68F1C1(a)microsoft.com... >I mean, FlashMedia Card, such as SdCard, sometimes can't be ejected by > IOCTL_STORAGE_EJECT_MEDIA. > > Echo > > "Uwe Sieber" wrote: > >> >> >> 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! >> >>>>>>> >> >>>>>>> >>
From: Pavel A. on 14 Jan 2007 08:40 "Uwe Sieber" wrote: ..... > 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. Maybe this is controlled by a Local/Group policy "Devices: allow format and eject removable media" --PA
From: Pavel A. on 14 Jan 2007 08:44 "Uwe Sieber" wrote: > 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. Internal device (USB or even PCI) can be electronically powered down or removed from the bus, especially in laptop platforms - has same effect as surprise removal. --PA
From: Uwe Sieber on 14 Jan 2007 10:28
Pavel A. wrote: > "Uwe Sieber" wrote: > .... >> 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. > > Maybe this is controlled by a Local/Group policy > "Devices: allow format and eject removable media" Just tried it: Doesn't help. It also doesn't help for IOCTL_STORAGE_EJECT_MEDIA because there seems to be no way to get the required handle to the storage volume. Uwe |