×
Namespaces

Variants
Actions

Archived:如何用Symbian C++代码启动midlet

From Nokia Developer Wiki
Jump to: navigation, search

Archived.png存档: 这篇文章是存档,因为考虑到今天它与第三方开发者建立商业解决方案不相关。

Article Metadata

一个简单的示例演示了如何用C++代码启动一个midlet程序

#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();
}
This page was last modified on 23 October 2013, at 08:11.
114 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.

×