Symbian3/SDK/Source/GUID-9D871368-ADB9-5588-A1F3-39A432F4F32E.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Thu, 21 Jan 2010 18:18:20 +0000
changeset 0 89d6a7a84779
permissions -rw-r--r--
Initial contribution of Documentation_content according to Feature bug 1266 bug 1268 bug 1269 bug 1270 bug 1372 bug 1374 bug 1375 bug 1379 bug 1380 bug 1381 bug 1382 bug 1383 bug 1385

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept xml:lang="en" id="GUID-9D871368-ADB9-5588-A1F3-39A432F4F32E"><title>Command Line Parsing </title><prolog><metadata><keywords/></metadata></prolog><conbody><p>Command Line Parsing provides access to arguments passed on the command-line. </p> <p>Conventional C and C++ programs receive their arguments from <codeph>main(
        int argc, char* argv[] )</codeph>. On Symbian platform, programs are invoked through an <codeph>E32Main()</codeph> function taking no arguments. Most Symbian programs are launched through a graphical shell rather than through a command-line. The common exceptions are <filepath>.exe</filepath> s on the PC platform, which can be run from a Windows command prompt. </p> <p>For <filepath>.exe</filepath> programs, control is received through the <codeph>E32Main()</codeph> function, which does not supply arguments. Instead, access to arguments is provided by <xref href="GUID-CE114EA5-A084-39A5-9F48-14344AB5BDBA.dita"><apiname>CCommandLineArguments</apiname></xref>. 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. </p> <p>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 as the following: </p> <codeblock id="GUID-CA0EBC3E-1FB5-5E39-8790-DE3131DB1B77" xml:space="preserve">TInt argLen = User::CommandLineLength();
HBufC16* hBuf = HBufC::NewL( argLen );
TPtr tPtr = hBuf-&gt;Des();
User::CommandLine( tPtr );</codeblock> <p>However, the arguments are in a raw form. For convenience, the <codeph>CCommandLineArguments</codeph> 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. </p> </conbody></concept>