The official MFC way is to: - derive a class from CCommandLineInfo and overide CCommandLineInfo::ParseParam - call CWinApp::ParseCommandLine in your overide of CWinApp::InitInstance using an instance of your class derived from CCommandLineInfo. When a new instance of your application starts CWinApp::ParseCommandLine slices the command line into tokens and chucks each on in turn into "YourDerivedClass"::ParseParam. ParseParam can do whatever it likes with the tokens it gets - raise or lower flags, set global state, you name it. If you want a simple class to explore these concepts try this for size:
class simple_command_line_parser : public CCommandLineInfo
{
public:
void ParseParam( const wchar_t* parameter, BOOL, BOOL )
{
::AfxMessageBox( parameter );
}
};
All it does is display the parameters it recieves in a message box. You'd use it by adding the following two line to your App's InitInstance:
simple\_command\_line\_parser sclp;
ParseCommandLine( sclp );
Anyway, hope that helps! Ash