In article <36863@palm-dev-forum>, "Alan Ingleby"
<[EMAIL PROTECTED]> wrote:
> That should do it.
>
> Regards,
>
> Alan Ingleby
>
> "Rick Kier" <[EMAIL PROTECTED]> wrote in message
> news:36754@palm-dev-forum...
> >
> > "Alan Ingleby" <[EMAIL PROTECTED]> wrote in
> > <36743@palm-dev-forum>:
> >
> > >
> > >Try writing to the DB. Won't that tell you?
> >
> > Actually, we are scanning all of the DBs. Maybe we could try turning off
> > the "Read Only" attribute? What do you think?
> >
> >
> > >
> > >Alan Ingleby
> > >
> > >"Rick Kier" <[EMAIL PROTECTED]> wrote in message
> > >news:36725@palm-dev-forum...
> > >>
> > >> Hi all,
> > >>
> > >> We are just about ready to release our app for beta test. Decided to
> > >> test on PalmOS 2.0. We are unable to determine whether a DB is in
> > >> rom or not. The code we use works fine on PalOS 3.x.
No, trying to write to the database may not be enough. The hard part is to
differentiate between a readonly database in RAM (attribute readonly set)
and a database in ROM. If you try to change the attributes of a ROM
database with DmSetDatabaseInfo, the system will crash instead of
returning an error code (at least on some systems). So you have to know,
whether the database is in ROM, before trying to change the attributes.
I solved it by testing, whether the localId of the database is a pointer
or a handle, like this:
if (MemLocalIDKind(localId) == memIDHandle)
rom = false; else rom = true;
Testing the heap flags, like the following code segment, does not work on
PalmOS 2.0.5 (I tested it on on POSE and on the real device).
if (MemLocalIDKind(localId) == memIDHandle)
heap = MemHandleHeapID(h); else heap = MemPtrHeapID(h);
ui = MemHeapFlags(heap);
if ((ui & memHeapFlagReadOnly) == memHeapFlagReadOnly) rom = true;
else rom = false;
And anyway, in SDK 3.5 the heap flags aren't in the public distribution
anymore. They used to be in "MemoryMgrPrv.h". So, I concluded, that both
methods are not really documented, but the chances that the first method
fails on a future system is smaller (at least not bigger) than the second
method, which fails already on at least one OS version.
--
Remo Hofer <[EMAIL PROTECTED]>
http://www.geocities.com/SiliconValley/Cable/5206/
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/