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. Help on Command Line Parameters

Help on Command Line Parameters

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
3 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.
  • W Offline
    W Offline
    WinAPILearner
    wrote on last edited by
    #1

    Hi, In a Win32 Application I would like to check if command line parameters /b /a is provided. The Messagebox show me the parametters like /b /a but the if condition do not met it alwasy the else statment that apply. if ("/b" == szCmdLine || szCmdLine == "/a") { MessageBox (NULL, szCmdLine,"met",0); } else { MessageBox (NULL, szCmdLine,"Not met",0); } I did also chcked "//b" == szCmdLine. What I am missing? Regards.

    V D 2 Replies Last reply
    0
    • W WinAPILearner

      Hi, In a Win32 Application I would like to check if command line parameters /b /a is provided. The Messagebox show me the parametters like /b /a but the if condition do not met it alwasy the else statment that apply. if ("/b" == szCmdLine || szCmdLine == "/a") { MessageBox (NULL, szCmdLine,"met",0); } else { MessageBox (NULL, szCmdLine,"Not met",0); } I did also chcked "//b" == szCmdLine. What I am missing? Regards.

      V Offline
      V Offline
      vcplusplus
      wrote on last edited by
      #2

      if szCmdLine contains other parameters besides /a or /b, you will need to do this. if (szCmdLine.Find("/b") >= 0 || szCmdLine.Find("/a") >= 0) { MessageBox (NULL, szCmdLine,"met",0); } else { MessageBox (NULL, szCmdLine,"Not met",0); }

      1 Reply Last reply
      0
      • W WinAPILearner

        Hi, In a Win32 Application I would like to check if command line parameters /b /a is provided. The Messagebox show me the parametters like /b /a but the if condition do not met it alwasy the else statment that apply. if ("/b" == szCmdLine || szCmdLine == "/a") { MessageBox (NULL, szCmdLine,"met",0); } else { MessageBox (NULL, szCmdLine,"Not met",0); } I did also chcked "//b" == szCmdLine. What I am missing? Regards.

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

        Use Paul DiLascia's CCommandLineInfoEx class for this.


        "Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow

        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