Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. how to get command line arguments in MFC

how to get command line arguments in MFC

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestionannouncement
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hemlat
    wrote on last edited by
    #1

    Hi, I need to execute my project exe through command prompt. 1) If I give path of exe in command prompt(one argument) then it should execute GUI version of Project. 2) If I give two arguments in command prompt then it should execute CLI version of Project. How can I get command line arguments In MFC.In windows programming we are having int _tmain(int argc, _TCHAR* argv[]) main function.But how can I do it in MFC.

    D C N 3 Replies Last reply
    0
    • H hemlat

      Hi, I need to execute my project exe through command prompt. 1) If I give path of exe in command prompt(one argument) then it should execute GUI version of Project. 2) If I give two arguments in command prompt then it should execute CLI version of Project. How can I get command line arguments In MFC.In windows programming we are having int _tmain(int argc, _TCHAR* argv[]) main function.But how can I do it in MFC.

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      hemlat wrote:

      But how can I do it in MFC.

      You have access to __argc and __argv whether you use MFC or not. Also check out the app's m_lpCmdLine member.

      "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

      H 1 Reply Last reply
      0
      • D David Crow

        hemlat wrote:

        But how can I do it in MFC.

        You have access to __argc and __argv whether you use MFC or not. Also check out the app's m_lpCmdLine member.

        "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

        H Offline
        H Offline
        hemlat
        wrote on last edited by
        #3

        thanks for your reply.This is what I needed.

        1 Reply Last reply
        0
        • H hemlat

          Hi, I need to execute my project exe through command prompt. 1) If I give path of exe in command prompt(one argument) then it should execute GUI version of Project. 2) If I give two arguments in command prompt then it should execute CLI version of Project. How can I get command line arguments In MFC.In windows programming we are having int _tmain(int argc, _TCHAR* argv[]) main function.But how can I do it in MFC.

          C Offline
          C Offline
          Chris Losinger
          wrote on last edited by
          #4

          there are a bunch of command line parser classes out there, to take care of splitting the cmd line into flags and options. for example: CCmdLine - command line parser[^]

          image processing toolkits | batch image processing

          1 Reply Last reply
          0
          • H hemlat

            Hi, I need to execute my project exe through command prompt. 1) If I give path of exe in command prompt(one argument) then it should execute GUI version of Project. 2) If I give two arguments in command prompt then it should execute CLI version of Project. How can I get command line arguments In MFC.In windows programming we are having int _tmain(int argc, _TCHAR* argv[]) main function.But how can I do it in MFC.

            N Offline
            N Offline
            nyeboy
            wrote on last edited by
            #5

            LPTSTT strCmdLine = GetCommandLine(); You should do next?

            studing is processing in this life.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups