I've had problems passing parameters to applications via SysAppLaunch because the PalmOS was deallocating the parameter block upon exit from the caller application. Try this code for the caller application:testtype *returnvp;
Err err;
LocalID dbID;

dbID = DmFindDatabase(0, "Application");
returnvp = MemPtrNew (sizeof(testtype));
MemPtrSetOwner(test, 0); // Set the owner to be the PalmOS
if (dbID) {
  err = SysAppLaunch (0, dbID, 0, 32768, 0, (DWord *) test);
}

Keep in mind that, when changing the owner, you are preventing PalmOS from deallocating test. Don't forget to do it yourself somewhere, or you'll have a serious memory leak - because it survives past the end of the application.
 
 

Chris DiPierro wrote:

I've successfully used SysAppLaunch and customized launch codes to pass
DWords back and forth, but I'm having a few conceptual problems getting my
mind around how to make it work to pass structures around.

For instance, if I have:

typedef struct
{
  Char name[40];
  Int value;
} testtype;

I can do something like this in the calling application:
testtype *returnvp;
Err err;
LocalID dbID;

dbID = DmFindDatabase(0, "Application");
returnvp = MemPtrNew (sizeof(testtype));
if (dbID) {
  err = SysAppLaunch (0, dbID, 0, 32768, 0, (DWord *) test);
}

And something like this in the returning app:
testtype *test;
if (cmd == 32768) {
  test = MemPtrNew (sizeof(testtype));
  StrCopy (test->name, "Bob");
  test->value = 5;
  return ((DWord)test);
}

While it builds fine, and I can test that the app launches fine (I can put a
WinDrawChars in the above code), I can't get the correct values out of the
app that launches this. However, if I simply use DWord's instead, all works
fine...Obviously I'm doing something silly, can someone point it out to me.
Thanks.

--
Sergio Carvalho
---------------
[EMAIL PROTECTED]

If at first you don't succeed, skydiving is not for you
 

Reply via email to