At 11:50 AM 8/6/2004, you wrote: i can use DmGetAppInfoID to get the Local Id of a open database but how can i write there?
thanx
Here's a distillation of some code we use for this purpose. Note that it's (uncompiled) C++ code, that not all appropriate error checking is shown, and that the definition of appInfoStrID (see CategoryInitialize) has to come from somewhere.
void writePalmAppInfo(DmOpenRef dbRef, MemPtr pInfo, UInt32 infoSize)
{
UInt16 cardNo;
LocalID dbID;
DmOpenDatabaseInfo(dbRef, &dbID, 0, 0, &cardNo, 0); // Reuse the existing Palm AppInfo block, or get a new one if it's
// not the right size. UInt32 totalSize = sizeof(AppInfoType) + infoSize;
LocalID id = DmGetAppInfoID(dbRef);
MemPtr pPalmAIB = 0;
if (id != 0)
MemPtr pPalmAIB = MemLocalIDToLockedPtr(id, cardNo); MemPtr pOldPalmAIB = 0;
if (pPalmAIB != 0 && MemPtrSize(pPalmAIB) != totalSize) {
// Existing block isn't the right size. Save it in pOldPalmAIB
// so we can free it later.
pOldPalmAIB = pPalmAIB;
pPalmAIB = 0;
} if (pPalmAIB == 0) { MemHandle handle = DmNewHandle(dbRef, totalSize);
if (handle != 0) { LocalID appInfoID = MemHandleToLocalID(handle);
if (DmSetDatabaseInfo(cardNo, dbID, 0, 0, 0, 0, 0, 0, 0,
&appInfoID, 0, 0, 0) == errNone)
{
if (pOldPalmAIB != 0)
MemPtrFree(pOldPalmAIB);
pPalmAIB = MemHandleLock(handle);
} else {
MemHandleFree(handle);
}
}
} if (pPalmAIB != 0) {
CategoryInitialize((AppInfoType*)pPalmAIB, appInfoStrID);
// Write our data immediately following the part of the
// appInfo block that the above call initialized:
DmWrite(pPalmAIB, sizeof(AppInfoType), pInfo, infoSize);
MemPtrUnlock(pPalmAIB);
}
}
-- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
