Command line arguments.
| Wed, 2003-10-08 09:44 | |
|
Hi group I want to launch an app from another passing it an argument this is
my code: -----------------------------CalledApp----------------------------------- CCommandLineArguments* args = CCommandLineArguments::NewLC(); if (args->Count() > 1) { //Access thi param args->Arg(1); *****//This line always return me \System\Apps\MyApp\MyApp.APP. Why??*** } else { iEikonEnv->InfoMsg(args->Arg(0)); } CleanupStack::PopAndDestroy(); -------------------------------------------------------------------------- And to launch the app I do something like this: --------------------Caller App------------------------------------------- TFileName AppToLaunch; TBuf<200> iDoc; AppToLaunch = _L("z:\\System\\Apps\\MyAppName\\MyAppName.APP"); iDoc = _L("aParam"); //This is the argument. CApaCommandLine* cmdLine = CApaCommandLine::NewLC(); cmdLine->SetDocumentNameL(iDoc); <--//Here I pass the argument I'm not sure if this instruction is well. cmdLine->SetLibraryNameL(AppToLaunch); cmdLine->SetCommandL(EApaCommandRun); RApaLsSession ls; User::LeaveIfError(ls.Connect()); TInt initialAppCount; ls.EmbeddableAppCount( initialAppCount ); CleanupClosePushL(ls); User::LeaveIfError(ls.StartApp(*cmdLine)); CleanupStack::PopAndDestroy(2); ------------------------------------------------------- When I access to args->Arg(1) or args->Arg(2), where the argument must be in, always return me this path \System\Apps\MyApp\MyApp.APP Any idea about how to launch an app with an argument and then recovery this argument from the launched app?? Thx in advance. ![]() ![]() |
|







Forum posts: 363
The code you have pasted should work just fine - looks like the error could be somewhere else. If you have not seen this link yet, have a look here:
http://www.newlc.com/article.php3?id_article=143
Cheers,
Pawel
Forum posts: 13
I must do anything more??
My app must support document??
The called app reads the param in the MyAppUi::ConstructL method.
Someone told me that this issue is only in the emulator.
Thx.
Forum posts: 363
Overriding this should work:
CEikAppUi::ProcessCommandParametersL(TApaCommand aCommand,TFileName& aDocumentName,const TDesC8& aTail)
There is more info in the Symbian documentation.
Cheers,
Pawel
Forum posts: 2009
The methods will be automatically called by the framework with your doc (iDoc) in the aFilename parameter.
{
if(aDoOpen)
{
// Do what you want
// (aFilename is your doc name)
...
}
return(NULL);
}
Eric Bustarret
NewLC Founder & CEO / Professional Symbian OS Consultant
The methods will be automatically called by the framework with your doc (iDoc) in the aFilename parameter.
{
if(aDoOpen)
{
// Do what you want
// (aFilename is your doc name)
...
}
return(NULL);
}
Forum posts: 363
Your App Ui owns the document so you can always access it via the Document() method after it has been created.
Cheers,
Pawel
Forum posts: 26
Calling app:
TThreadId threadId;
_LIT( KAppExtension, ".app" );
iCmdLine = CApaCommandLine::NewLC();
TFullName iExeFileName = _L("c:\\system\\apps\\basicapp\\basicapp");
TFileName newname = iExeFileName;
newname.Append( KAppExtension );
_LIT( KDoc, "c:\\documents\\app.dat" );
iCmdLine->SetDocumentNameL( KDoc );
iCmdLine->SetLibraryNameL( newname );
iCmdLine->SetCommandL( EApaCommandRun );
iCmdLine->SetTailEndL( _L8( "String" ) );
RApaLsSession ls;
User::LeaveIfError( ls.Connect() );
CleanupClosePushL( ls );
User::LeaveIfError( ls.StartApp( *iCmdLine ) );
CleanupStack::PopAndDestroy( 2 ); // iCmdLine, close ls
Called app has this code:
CFileStore* CQBasicAppDocument::OpenFileL( TBool aDoOpen, const TDesC& /*aFilename*/, RFs& /*aFs*/ )
{
if( aDoOpen )
{
// (aFilename is your doc name)
TInt len = RProcess().CommandLineLength();
iCmdlineBuffer = HBufC::NewLC( len );
TPtr cmdline( iCmdlineBuffer->Des() );
RProcess().CommandLine( cmdline );
}
return(NULL);
}
however it is never called.
And also this:
GLDEF_C TInt E32Dll(TDllReason)
{
TInt len = RProcess().CommandLineLength();
if( len > 0 )
{
TBuf<256> cmdLineBuf;
RProcess().CommandLine( cmdLineBuf );
}
TBuf<256> cmdLineBuf;
RProcess().CommandLine( cmdLineBuf );
return KErrNone;
}
len is always 0 and cmdLineBuf never contains anything..
If someone has some ideas please let me know.
Niimidan