Thursday, June 26, 2008

How to launch a UI application with Arguments and Handle in Launched UI application

H to launch a application with Arguments.

LaunchApplicationWithArgumentL(const TDesC& aExeName, const TDesC8& aArg = KNullDesC8())
{
CApaCommandLine* commandLine = CApaCommandLine::NewLC();
commandLine->SetCommandL(EApaCommandRun);
commandLine->SetExecutableNameL(aExecName);
commandLine->SetTailEndL(aArg);
RApaLsSession apaLsSession;
User::LeaveIfError(apaLsSession.Connect());
CleanupClosePushL(apaLsSession);
User::LeaveIfError(apaLsSession.StartApp(*commandLine));
CleanupStack::PopAndDestroy();
CleanupStack::PopAndDestroy(commandLine);
}


Handle Arguments in UI Application.

Over ride the virtual function ProcessCommandParametersL() of AppUi Class. 3rd parameter of the function aTail contains application parameters

TBool CMySymbianAppUi::ProcessCommandParametersL(TApaCommand aCommand, TFileName &aDocumentName, const TDesC8 &aTail)
{
iLogger.WriteFormat(_L("ProcessCommandParametersL %d"), aTail.Length());
}

No comments:

stats counter