Michael
Fri May 07 10:58:23 CDT 2004
Wasn't try to indicate it's not a problem. Was just proposing a "solution".
Re-use whatever handler you invoke when the card is yanked. It would be
nice if you could detect this situation based on a power-on event or other
event instead of ReadFile/WriteFile errors out w/ERROR_ACCESS_DENIED, but if
that's the way you have to detect it, so be it.
Re: possible corruption issues, you might try flushing every write.
--
Michael Salamone [eMVP]
Entrek Software, Inc.
www.entrek.com
"The PocketTV Team" <do-not-reply-by-email@pockettv.com> wrote in message
news:eqU7U4uMEHA.556@TK2MSFTNGP10.phx.gbl...
> "Michael J. Salamone [eMVP]" <mikesa#at#entrek#dot#com> wrote in message
> news:efynO%23qMEHA.2244@TK2MSFTNGP10.phx.gbl...
> > File handles become un-usable if you yank the card, too (while device is
> > still powered on). So you need to handle that type of situation anyway.
>
> Yes, of course, but that's different. That'a a fatal situation: the file
> becomes permanently un-usable because the card has been removed.
>
> But that's not what the problem is about, here. The problem here is that
> case where power is suspended/resumed, without removing any removanle
> storage.
>
>
> > Is there any notification? That is, if you use SHChangeNotifyRegister
and
> > the card is pulled, you would get WM_FILECHANGEINFO/SHCNE_MEDIAREMOVED
> > message if the user pulled the card out. If your app is using storage
> card
> > files, then it already is (or should be) registering for this
> notification,
> > and properly handling it.. WM_DEVICECHANGE also works on some devices,
> but
> > I found SHChangeNotifyRegister is more reliable.
>
> Again, that's not the question. The problem does not involve removing any
> card.'
>
> And it makes it very complicated for apps to deal with re-opening files
each
> time an error occurs because of this problem.
>
> In fact MSFT is now looking seriously at this issue, since it also breaks
> most of MSFT's own apps. The only one that correctly deals with
re-opening
> files on removable storage after power suspend/resume is WMP. All the
ather
> MSFT apps break in this case.
>
>
> > Anyway, do you get that same notification, or any other notification, on
> > suspend/resume? That would be the real problem, if no notification was
> > sent. Otherwise use the same handling you have for
> > WM_FILECHANGEINFO/SHCNE_MEDIAREMOVED or WM_DEVICECHANGE.
>
> Well, ReadFile returns an arror, so you get notified, in a way. But
that's
> not what is supposed to happen.
>
> In WinCE 3.0 (and earlier), all handles to storage card files were
remounted
> correctly and automatically, sometimes after a small delay during which
> ReadFile would return ERROR_ACCESS_DENIED, ERROR_NOT_READY or
> ERROR_DEVICE_NOT_AVAILABLE. so you just needed to retry, as described
here:
>
>
http://support.microsoft.com/default.aspx?scid=kb;en-us;811693
>
> But now, in WinCE 4.2, you can retry as much as you want, the handles are
> never remounted.
>
> That's causing all sorts of troubles when people power off their devices,
> while running apps have files opened on Storage Cards.
>
> And I don't even want to think of the disaster if some running apps are
> themself installed on the Storage Cards!
>
>
> > --
> >
> > Michael Salamone [eMVP]
> > Entrek Software, Inc.
> > www.entrek.com
> >
> >
> >
> > "The PocketTV Team" <do-not-reply-by-email@pockettv.com> wrote in
message
> > news:eqo$%23vnMEHA.3292@TK2MSFTNGP11.phx.gbl...
> > > On WM2003 (and WM2003-SE), when you open a file located on a storage
> card,
> > > the file handle become un-usable after power OFF/ON (i.e. power
> > > suspend/resume).
> > >
> > > This problem is described here in more details:
> > >
> > >
http://www.pocketpcthoughts.com/forums/viewtopic.php?t=27614
> > >
> > > If you app opens files on a storage card (or in the application home
> > folder,
> > > which can be located on the Storage Card), you should be aware of this
> > > issue, and implement the necessary workarounds, if needed. If you
> don't,
> > > you application can mis-behave after the user presses the Power
button,
> or
> > > it can cause data corruption.
> > >
> > > This issue affects some (maybe all) Pocket PC 2003, including the
> Toshiba
> > > e800 series.
> > >
> > > I believe that this problem also affects Smartphone 2003 devices,
> although
> > > not all Smartphones are capable of suspending (The Samsung i600 does
> > suspend
> > > when closed, if no earphone jacked is used).
> > >
> > >
> >
> >
>
>