Freigeben über


CCommandLineInfo::ParseParam

The framework calls this function to parse/interpret individual parameters from the command line. The second version is only available in Unicode projects.

virtual void ParseParam( 
   const char* pszParam, 
   BOOL bFlag, 
   BOOL bLast 
);
virtual void ParseParam( 
   const TCHAR* pszParam,  
   BOOL bFlag, 
   BOOL bLast
);

Parameters

  • pszParam
    The parameter or flag.

  • bFlag
    Indicates whether pszParam is a parameter or a flag.

  • bLast
    Indicates if this is the last parameter or flag on the command line.

Remarks

CWinApp::ParseCommandLine calls ParseParam once for each parameter or flag on the command line, passing the argument to pszParam. If the first character of the parameter is a '-' or a '/', then it is removed and bFlag is set to TRUE. When parsing the final parameter, bLast is set to TRUE.

The default implementation of this function recognizes the following flags: /p, /pt, /dde, /Automation, and /Embedding, as shown in the following table:

Command-line argument

Command executed

app

New file.

app filename

Open file.

app /p filename

Print file to default printer.

app /pt filename printer driver port

Print file to the specified printer.

app /dde

Start up and await DDE command.

app /Automation

Start up as an OLE automation server.

app /Embedding

Start up to edit an embedded OLE item.

app /Register

app /Regserver

Informs the application to perform any registration tasks.

app /Unregister

app /Unregserver

Informs the application to perform any un-registration tasks.

This information is stored in m_bRunAutomated, m_bRunEmbedded, and m_nShellCommand. Flags are marked by either a forward-slash '/' or hyphen '-'.

The default implementation puts the first non-flag parameter into m_strFileName. In the case of the /pt flag, the default implementation puts the second, third, and fourth non-flag parameters into m_strPrinterName, m_strDriverName, and m_strPortName, respectively.

The default implementation also sets m_bShowSplash to TRUE only in the case of a new file. In the case of a new file, the user has taken action involving the application itself. In any other case, including opening existing files using the shell, the user action involves the file directly. In a document-centric standpoint, the splash screen does not need to announce the application starting up.

Override this function in your derived class to handle other flag and parameter values.

Requirements

Header: afxwin.h

See Also

Concepts

CCommandLineInfo Class

CCommandLineInfo Members

Hierarchy Chart

CWinApp::ParseCommandLine