Hello everyone,
First, I am sorry for the long email. I don't know how to write it shorter.
I want to run my application from the "send contact" menu in the contact
(address book app).
I read the recipe in Palmsource about running the application from the send
menu,
The recipe said
Begin quote
...
Check that the library is not already installed:
...
if (! SysLibFind(kSmsLibName, &refNum))
return;
Then install the library. This sets up the dispatch table and registers the
exchange library with the Exchange Manager:
if (!SysLibInstall(MyInstallDispatcher, &refNum))
...
End quote
I need to check and install the local exchange library, not the Sms lib
After checking the lib if (SysLibFind(exgLocalLibName, &refNum)), how can I
install the library using SysLibInstall()? I don't know how to get dispatch
table (MyInstallDispathcher). The recipe makes me think it is simple to use
SysLibInstall()
I follow the function AESLib_LoadLibrary() in AESLib_inline.h and do this
Err LoadLocalExchangerLibrary()
{
Err err;
MemHandle codeRscH = 0;
SysLibEntryProcPtr codeRscP = 0;
UInt16 cardNo = 0;
LocalID dbID = 0;
DmSearchStateType searchState;
DmOpenRef dbR = 0;
SysLibTblEntryPtr entryP = 0;
Boolean libInROM = false;
UInt16 refNum;
DmGetNextDatabaseByTypeCreator(true, &searchState, sysFileTExgLib,
sysFileCLocalLib, true, &cardNo, &dbID);
if (!dbID)
return sysErrLibNotFound;
libInROM = (MemLocalIDKind(dbID) != memIDHandle);
if (0 == (dbR = DmOpenDatabase(cardNo, dbID, dmModeReadOnly)))
return sysErrNoFreeRAM;
if (0 == (codeRscH = DmGet1Resource(sysResTAppCode, 1))) {
// I got stuck in this line, codeRscH is 0
// what should be the value of the 2nd param
// in DmGet1Resource() in this case?
ErrNonFatalDisplay("Can't get library rsrc");
err = DmGetLastErr();
err = sysErrLibNotFound;
} else {
codeRscP = (SysLibEntryProcPtr)MemHandleLock(codeRscH);
err = SysLibInstall(codeRscP, &refNum);
if (!err && !libInROM) {
DmDatabaseProtect(cardNo, dbID, true);
}
}
DmCloseDatabase(dbR);
dbR = 0;
if (err) {
refNum = sysInvalidRefNum;
if (codeRscP && !libInROM) {
MemPtrUnlock(codeRscP);
DmReleaseResource(codeRscH);
}
} else {
entryP = SysLibTblEntry(refNum);
entryP->dbID = dbID;
if (libInROM) {
entryP->codeRscH = 0;
} else {
entryP->codeRscH = codeRscH;
}
}
return err;
}
Could someone please tell me what I do wrong.
Also, in the recipe, toward the end, it said "If the application has multiple
segments, you have to load and lock each segment that contains a part of the
Exchange Library."
My application has multiple segments, which segment will contains a part of the
Exchange Library? How do I know? Could you explain to me, please.
Many thanks for reading my email and for your help.
tnn
--
For information on using the PalmSource Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/