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. Input from Commandline.

Input from Commandline.

Scheduled Pinned Locked Moved C / C++ / MFC
c++databasejson
4 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.
  • K Offline
    K Offline
    krishna_CP
    wrote on last edited by
    #1

    HI, I written one application using MFC Appwizard exe.In that application iam browsing a file in my PC and Parsing into required form and loading in a database table. Till now my application working fine. But the requirement changed as i need to take the input from Commandline and need to Run the application as batch file. MY Requirement is i need to take two parameters in commandline one is File path and Another one is Table Name. I need your Guidance. Thanks, Krishna.

    L G A 3 Replies Last reply
    0
    • K krishna_CP

      HI, I written one application using MFC Appwizard exe.In that application iam browsing a file in my PC and Parsing into required form and loading in a database table. Till now my application working fine. But the requirement changed as i need to take the input from Commandline and need to Run the application as batch file. MY Requirement is i need to take two parameters in commandline one is File path and Another one is Table Name. I need your Guidance. Thanks, Krishna.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      What about using GetCommandLine()?

      Life is a stage and we are all actors!

      1 Reply Last reply
      0
      • K krishna_CP

        HI, I written one application using MFC Appwizard exe.In that application iam browsing a file in my PC and Parsing into required form and loading in a database table. Till now my application working fine. But the requirement changed as i need to take the input from Commandline and need to Run the application as batch file. MY Requirement is i need to take two parameters in commandline one is File path and Another one is Table Name. I need your Guidance. Thanks, Krishna.

        G Offline
        G Offline
        Garth J Lancaster
        wrote on last edited by
        #3

        I use this, from right here on CP CCmdLine - command line parser[^] 'g'

        1 Reply Last reply
        0
        • K krishna_CP

          HI, I written one application using MFC Appwizard exe.In that application iam browsing a file in my PC and Parsing into required form and loading in a database table. Till now my application working fine. But the requirement changed as i need to take the input from Commandline and need to Run the application as batch file. MY Requirement is i need to take two parameters in commandline one is File path and Another one is Table Name. I need your Guidance. Thanks, Krishna.

          A Offline
          A Offline
          Aescleal
          wrote on last edited by
          #4

          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

          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