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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to read command line parameters

How to read command line parameters

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
4 Posts 3 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.
  • G Offline
    G Offline
    gmlnd
    wrote on last edited by
    #1

    I have a CFormView based project that cleans out the system. For example, it deletes cookies, and temp files. When I run the program, the user can select checkboxes and click on a button to wash. Is there any way to adjust the program so when the user clicks the .exe file, my program reads the command and does the wash automatically without opening the actual program?

    H 1 Reply Last reply
    0
    • G gmlnd

      I have a CFormView based project that cleans out the system. For example, it deletes cookies, and temp files. When I run the program, the user can select checkboxes and click on a button to wash. Is there any way to adjust the program so when the user clicks the .exe file, my program reads the command and does the wash automatically without opening the actual program?

      H Offline
      H Offline
      Hans Dietrich
      wrote on last edited by
      #2

      azi_games wrote: my program reads the command and does the wash automatically Yes, this is easy and commonly done. You can store parameters for program in INI file, in Registry, or even read them for command line - see XGetopt for an example of reading command line. azi_games wrote: without opening the actual program I do not understand what you mean. If the user clicks on a program, he expects to see something happen. If nothing happens, he will probably click again. After three or four times, he will probably think your progam doesn't work, and will delete it from system. Of course, if this is really what you want to do, then there are ways to make a program invisible - e.g., on NT, make it a service. Or make your program's main window the child of an invisible window - it will not even show in the taskbar. Best wishes, Hans

      G 1 Reply Last reply
      0
      • H Hans Dietrich

        azi_games wrote: my program reads the command and does the wash automatically Yes, this is easy and commonly done. You can store parameters for program in INI file, in Registry, or even read them for command line - see XGetopt for an example of reading command line. azi_games wrote: without opening the actual program I do not understand what you mean. If the user clicks on a program, he expects to see something happen. If nothing happens, he will probably click again. After three or four times, he will probably think your progam doesn't work, and will delete it from system. Of course, if this is really what you want to do, then there are ways to make a program invisible - e.g., on NT, make it a service. Or make your program's main window the child of an invisible window - it will not even show in the taskbar. Best wishes, Hans

        G Offline
        G Offline
        gmlnd
        wrote on last edited by
        #3

        I mean that the program does something without opening up the window. I have found some information about this but it still is not clear to me. BOOL CMyApp::InitInstance() { LPSTR lpszCmd=GetCommandLine(); // parse lpszCmd if(command_line_keys_detected) { // do all your tasks here return FALSE; } // // original body of InitInstance // goes here // } I'm getting command_line_keys_detected error: undeclared identifier. I don't know how this is supposed to be declared. Thanks.

        D 1 Reply Last reply
        0
        • G gmlnd

          I mean that the program does something without opening up the window. I have found some information about this but it still is not clear to me. BOOL CMyApp::InitInstance() { LPSTR lpszCmd=GetCommandLine(); // parse lpszCmd if(command_line_keys_detected) { // do all your tasks here return FALSE; } // // original body of InitInstance // goes here // } I'm getting command_line_keys_detected error: undeclared identifier. I don't know how this is supposed to be declared. Thanks.

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

          It's a variable. It needs to be declared just like any other.

          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