Arguments in MFC

This is a discussion on Arguments in MFC within the Windows Programming forums, part of the Platform Specific Boards category; What's up I'm trying to figure out how to retrieve arguments in a MFC program. In a normal console program ...

  1. #1
    Registered User
    Join Date
    Mar 2006
    Location
    USA::Colorado
    Posts
    155

    Question Arguments in MFC

    What's up

    I'm trying to figure out how to retrieve arguments in a MFC program.

    In a normal console program you've got:
    Code:
    #include <iostream>
    
    using namespace std;
    
    int main (int argc, char *argv[])
    {
         cout << argv[1] << endl;
         system("pause");
         return 0;
    }
    and that would display something passed along with the file when it is about to be executed. Is there a hidden argv/argc in MFC? (I'm trying to pass variables to the program when it starts that could include /hidden or /off or /on or something along those lines..)

    Help will be greatly appreciated,

    Thanks in advance,

    Guitarist809
    ~guitarist809~

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,674
    You're CWinApp derived object has an inherited m_lpCmdLine member.
    Code:
    AfxGetApp()->m_lbCmdLine
    You can also use the Win32API call GetCommandLine(). Unlike argc/argv, the entire command line is in one string.

    gg

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    or use ParseCommandLine() to access the CCommandLineInfo object.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. MFC Controls and Thread Safety :: MFC
    By kuphryn in forum Windows Programming
    Replies: 0
    Last Post: 12-06-2002, 10:36 AM
  2. WIndows programming?
    By hostensteffa in forum Windows Programming
    Replies: 7
    Last Post: 06-07-2002, 08:52 PM
  3. Release MFC Programs & Dynamic MFC DLL :: MFC
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 05-18-2002, 06:42 PM
  4. Beginning MFC (Prosise) Part III - Now What? :: C++
    By kuphryn in forum C++ Programming
    Replies: 5
    Last Post: 03-03-2002, 05:58 PM
  5. MFC is Challenging :: C++
    By kuphryn in forum C++ Programming
    Replies: 8
    Last Post: 02-05-2002, 12:33 AM

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