Monday, August 14, 2006

Hello Friends,
Today we will discuss about "Command Line Arguments in Symbian".

If you have done some desktop programming, you understand that in main () function arguments we can get the command line passed to the program. If you ever thought how arguments passed to Symbian EXEs are handled. (How to pass arguments to Symbian EXE? to this i will post another post till then be pasence.)

As all Symbian programmers know that E32Main () function does to supply arguments, So how to handle the arguments or access the passed arguments.

The Trick is we have to use a API called "CCommandLineArguments"
Location: bacline.h
Link against: bafl.lib
Reference: C++ API reference » Command Line Parsing » CCommandLineArguments
Example:
void ReadAndWriteArgsL()
{
Console* console=Console::NewL(_L("Command-line arguments reader test"),
TSize(KConsFullScreen, KConsFullScreen));
CleanupStack::PushL( console );

//Create CommandLine Arguments and read it.
CCommandLineArguments* args=CCommandLineArguments::NewLC();
for (TInt i=0; iCount(); i++)
{
TPtrC argumentPrt(args->Arg(i));
console->Printf(_L("Arg %d == %S\n"), i, &argumentPrt);
}

CleanupStack::PopAndDestroy(2);
}

So what you say. Isn't it a small trick?
Coming up
========
* I will Post some more posts Symbian APIs.

Do write comments about this post or write to me at [skumar.brewdev@yahoo.com]

Thanks.
Sunil Kumar

No comments:

stats counter