Symbian
Symbian OS Library

SYMBIAN OS V9.3

[Index] [Spacer] [Previous] [Next]



How to parse command line arguments

Conventional C and C++ programs receive their arguments from main(int argc, char* argv[]). On Symbian OS, programs are invoked through an E32Main() function taking no arguments. For a program that is launched as a new process, the arguments are available as part of the process command line and may be obtained in full using code such as

TInt argLen = User::CommandLineLength();
HBufC16* hBuf = HBufC::NewL(argLen);
TPtr tPtr=hBuf->Des();
User::CommandLine (tPtr);

However, the arguments are in a raw form. For convenience, the CCommandLineArguments class provides functions to access the program name as argument 0, and each command-line argument as argument 1, 2 etc. Arguments beginning with a quote may contain blanks and doubled quotes. Arguments not beginning with a quote are terminated by a blank.

This class is not intended primarily for code running on a Symbian phone. Its main use is in parsing the arguments of WINC command-line utilities.