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
2 Posts 2 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'm trying to adjust my program so it runs in silent mode, meaning it does the work without opening up the main window for the user to click. I have the following code in my InitInstance function: This code does go to silent mode, but I need to adjust it a bit. When I get the command line, I want to be able to see if the lpszCmd is "/s", then run in silent mode, else, run in regular mode(open up the main window). I dont know how to adjust my program to do that. Is it possible? BOOL command_line_keys_detected; LPSTR lpszCmd=GetCommandLine(); // parse lpszCmd if(command_line_keys_detected) { // do all your tasks here CMainFrame* main = dynamic_cast(m_pMainWnd); main->GetCheckedItems(); CFileProgress dlgPrg; dlgPrg.DoModal(); return FALSE; }

    D 1 Reply Last reply
    0
    • G gmlnd

      I'm trying to adjust my program so it runs in silent mode, meaning it does the work without opening up the main window for the user to click. I have the following code in my InitInstance function: This code does go to silent mode, but I need to adjust it a bit. When I get the command line, I want to be able to see if the lpszCmd is "/s", then run in silent mode, else, run in regular mode(open up the main window). I dont know how to adjust my program to do that. Is it possible? BOOL command_line_keys_detected; LPSTR lpszCmd=GetCommandLine(); // parse lpszCmd if(command_line_keys_detected) { // do all your tasks here CMainFrame* main = dynamic_cast(m_pMainWnd); main->GetCheckedItems(); CFileProgress dlgPrg; dlgPrg.DoModal(); return FALSE; }

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

      Look at the CCommandLineInfo class. Its ParseParam() method can be overridden to handle your app's specific needs.

      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