where's my command line?

This is a discussion on where's my command line? within the Windows Programming forums, part of the Platform Specific Boards category; Hi, I'm writing a program in MS Visual C++, using the MFC AppWizzard. I want to be able to pass ...

  1. #1
    Unregistered
    Guest

    Unhappy where's my command line?

    Hi,

    I'm writing a program in MS Visual C++, using the MFC AppWizzard. I want to be able to pass a command line option to my program when I run it. How can I get to find out what command line the application was passed?

    Cheers,

    Phli Drew.

  2. #2
    zen
    zen is offline
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    The API function GetCommandLine() will return a pointer to the command line.
    zen

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    70
    If you have AppWizard generated application, look into your InitInstance () function, and you will see something like this

    CCommandLineInfo cmdInfo;
    ParseCommandLine (cmdInfo);
    if (!ProcessShellCommand (cmdInfo))
    return FALSE;


    >>> from MSDN help >>>

    1. After being created in InitInstance, the CCommandLineInfo object is passed to ParseCommandLine.

    2. ParseCommandLine then calls CCommandLineInfo::ParseParam repeatedly, once for each parameter.

    3. ParseParam fills the CCommandLineInfo object, which is then passed to ProcessShellCommand.

    4. ProcessShellCommand handles the command-line arguments and flags

    >>>>>>>>>>>>>>>>>>>>>>>


    If you want to process your own flags, you must derive a new class from CCommandLineInfo and override its ParseParam () function. There are some options like /p etc. which must be handled.

    See CCommandLineInfo::ParseParam () in the help for more.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21