CCommandLineInfo Class

Aids in parsing the command line at application startup.

class CCommandLineInfo : public CObject

Members

Public Constructors

Name

Description

CCommandLineInfo::CCommandLineInfo

Constructs a default CCommandLineInfo object.

Public Methods

Name

Description

CCommandLineInfo::ParseParam

Override this callback to parse individual parameters.

Public Data Members

Name

Description

CCommandLineInfo::m_bRunAutomated

Indicates the command-line /Automation option was found.

CCommandLineInfo::m_bRunEmbedded

Indicates the command-line /Embedding option was found.

CCommandLineInfo::m_bShowSplash

Indicates if a splash screen should be shown.

CCommandLineInfo::m_nShellCommand

Indicates the shell command to be processed.

CCommandLineInfo::m_strDriverName

Indicates the driver name if the shell command is Print To; otherwise empty.

CCommandLineInfo::m_strFileName

Indicates the file name to be opened or printed; empty if the shell command is New or DDE.

CCommandLineInfo::m_strPortName

Indicates the port name if the shell command is Print To; otherwise empty.

CCommandLineInfo::m_strPrinterName

Indicates the printer name if the shell command is Print To; otherwise empty.

CCommandLineInfo::m_strRestartIdentifier

Indicates the unique restart identifier for the restart manager if the restart manager restarted the application.

Remarks

An MFC application will typically create a local instance of this class in the InitInstance function of its application object. This object is then passed to CWinApp::ParseCommandLine, which repeatedly calls ParseParam to fill the CCommandLineInfo object. The CCommandLineInfo object is then passed to CWinApp::ProcessShellCommand to handle the command-line arguments and flags.

You can use this object to encapsulate the following command-line options and parameters:

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.

Derive a new class from CCommandLineInfo to handle other flags and parameter values. Override ParseParam to handle the new flags.

Inheritance Hierarchy

CObject

CCommandLineInfo

Requirements

Header: afxwin.h

See Also

Reference

CObject Class

Hierarchy Chart

CWinApp::ParseCommandLine

CWinApp::ProcessShellCommand