October 23, 2016
Hot Topics:

Application Launching

  • August 21, 2003
  • By Alex Gusev
  • Send Email »
  • More Articles »

Launching Applications From Your Own Programs

The System Manager API has several functions to allow you to programmatically run other applications. These are SysAppLaunch, SysUIAppSwitch and SysBroadcastActionCode.

SysBroadcastActionCode is the simplest. The operating system finds all UI applications and calls SysAppLaunch with the given launch code for each of them.

SysUIAppSwitch actually closes current application and switches to the called one.

SysAppLaunch launches the application with the given launch code and parameters. If you need to pass parameters to the launched application, you should grant ownership of allocated parameter block to the operating system (using MemPtrSetOwner or MemHandleSetOwner respectively for pointers and handles). Otherwise, the parameter block will get deleted before the launched application will be able to access it. A typical example of launching an application may look like the following:

#define cmdPrintChars     0x8000

Boolean PrintReport(const char* szText)
  DWord dwRes = 0;
  LocalID dbID = ::DmFindDatabase(0,"PalmPrint");
  if ( !dbID )
    return false;
  // Grant ownership to OS (if needed) here
  // In this sample it's not needed :)
  // MemPtrSetOwner(szText,0);

  Err err = ::SysAppLaunch( 0,
  return (err == 0);

Implementing A Custom Launch Code Handler

Taking into account all of the stuff we've discussed, an implementation of a custom launch code handler should seem to be a trivial thing! "All" you need to do is to organize one more 'case' in PilotMain and write the corresponding code chunk. Please don't forget that at this point your application has no access to global variables, so be careful!

As a simple example of all of the theory presented in this article, I've developed a test application that calls SysAppLaunch for itself and for a separate 'server' application. For simplicity (and frankly speaking because it really much simpler!) I've used the POL Object library. The CW wizard has created all of the standard files for both 'server' ("launchsrv") and 'client' ("launchapp") applications, The following code sample describes all needed:

Sample Code

Download the sample code from here: sample5.zip - 67 kb

Where to go

Starting with Palm OS 4.0, the Helper API was introduced. This API is another way to obtain inter-application communications. In my next article I'll tell you what this API is as well as show you when and how to use it.

About the Author

Alex Gusev started to play with mainframes in the end of the 1980s, using Pascal and REXX, but soon switched to C/C++ and Java on different platforms. When mobile PDAs seriously rose their heads in the IT market, Alex did it too. Now, he works at an international retail software company as a team leader of the Mobile R department, making programmers' lives in the mobile jungles a little bit simpler.

# # #

Page 2 of 2

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Thanks for your registration, follow us on our social networks to keep up-to-date
Rocket Fuel