×
Namespaces

Variants
Actions
Revision as of 01:32, 3 February 2010 by ltomuta (Talk | contribs)

Archived:Launching a midlet from Symbian C++ code (S60 2nd Edition)

From Nokia Developer Wiki
Jump to: navigation, search

A simple example (.exe) launching a midlet (Helloworld) from C++ code

#include <e32base.h>
#include <e32std.h>
 
const TInt KMaxCommandLine = 1024;
const TInt KMidletPort = 7049;
const TInt KMidletUidValue = 0x100009c4;
const TUid KMidletUid = {KMidletUidValue};
 
LOCAL_C void doLaunchL();
 
// midlet name
_LIT(KMidletName, "HelloWorld");
 
// KVM virtual machine location on ROM drive
_LIT(KMidRunROMLocation, "z:\\system\\programs\\kmidrun.exe");
 
// location of jad + jar
_LIT(KMidletJadLocation, "c:\\system\\apps\\MidLaunch\\HelloWorld.jad");
_LIT(KMidletJarLocation, "c:\\system\\apps\\MidLaunch\\HelloWorld.jar");
 
 
// main function called by E32
GLDEF_C TInt E32Main()
{
_LIT(KE32Main, "KE32Main");
 
__UHEAP_MARK;
CTrapCleanup* cleanup=CTrapCleanup::New(); // get a clean-up stack
TRAPD(error,doLaunchL());
 
__ASSERT_ALWAYS(!error,User::Panic(KE32Main,error));
delete cleanup; // destroy cleanup stack
__UHEAP_MARKEND;
 
return 0;
}
 
 
// actual launching of a midlet
LOCAL_C void doLaunchL()
{
TBuf<KMaxCommandLine> cmdLine;
_LIT(KSeparator, "*");
 
// cmd line syntax: PortNumber*MIDletUid*MIDletName*JarLocation*JadLocation*
 
cmdLine.AppendNum(KMidletPort);
cmdLine.Append(KSeparator);
 
// append a midlet uid in decimal format to the command line
TBuf<16> uidNum;
uidNum.Num(KMidletUid.iUid,EDecimal);
cmdLine.Append(uidNum);
cmdLine.Append(KSeparator);
 
// append a midlet name to the command line
cmdLine.Append(KMidletName);
cmdLine.Append(KSeparator);
 
// append a jar file location to the command line
cmdLine.Append(KMidletJarLocation);
cmdLine.Append(KSeparator);
 
// append a jad file location to the command line
cmdLine.Append(KMidletJadLocation);
cmdLine.Append(KSeparator);
 
// create a new process
RProcess process;
 
TInt error = process.Create(KMidRunROMLocation,cmdLine);
User::LeaveIfError(error);
 
// TODO: process should be renamed according to convention used with KVM
 
process.Resume();
process.Close();
}
65 page views in the last 30 days.
×