×
Namespaces

Variants
Actions

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

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.


Article Metadata
CompatibilityArticle
Created: giridharn (28 May 2007)
Last edited: hamishwillee (16 Aug 2013)

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();
}

Related articles

This page was last modified on 16 August 2013, at 09:23.
53 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×