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. Arguments to WinMain

Arguments to WinMain

Scheduled Pinned Locked Moved C / C++ / MFC
c++questionhardwaretutorialworkspace
4 Posts 3 Posters 1 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
    gunnar66
    wrote on last edited by
    #1

    Hi There!. I am a newcommer in MFC programming. How does one parse parameters passed as command line arguments in the Win32 environment? I know i can use lpCmdLine, but how do i do that? Can someone show me an example. By the way I am useing Embedded Visual c++

    M 1 Reply Last reply
    0
    • G gunnar66

      Hi There!. I am a newcommer in MFC programming. How does one parse parameters passed as command line arguments in the Win32 environment? I know i can use lpCmdLine, but how do i do that? Can someone show me an example. By the way I am useing Embedded Visual c++

      M Offline
      M Offline
      Mike Dimmick
      wrote on last edited by
      #2

      The lpCmdLine parameter is an exact copy of the command line passed to your program, including all spaces, quote marks, etc. If you want to treat this as separate arguments, you must split it. MFC supplies its own WinMain by default; however, you can override this if you wish. If you do so, call AfxWinInit to initialize MFC, and AfxWinTerm before returning. The MFC WinMain is implemented in winmain.cpp. It's rare to do this. Typically, you instead override InitInstance in your class derived from CWinApp. You can then access the command line from CWinApp's m_lpCmdLine parameter. MFC offers the CCommandLineInfo class and the ParseCommandLine function for helping with command lines. To add support for your own options, create a new class which inherits CCommandLineInfo. Then override ParseParam. Stability. What an interesting concept. -- Chris Maunder

      G 1 Reply Last reply
      0
      • M Mike Dimmick

        The lpCmdLine parameter is an exact copy of the command line passed to your program, including all spaces, quote marks, etc. If you want to treat this as separate arguments, you must split it. MFC supplies its own WinMain by default; however, you can override this if you wish. If you do so, call AfxWinInit to initialize MFC, and AfxWinTerm before returning. The MFC WinMain is implemented in winmain.cpp. It's rare to do this. Typically, you instead override InitInstance in your class derived from CWinApp. You can then access the command line from CWinApp's m_lpCmdLine parameter. MFC offers the CCommandLineInfo class and the ParseCommandLine function for helping with command lines. To add support for your own options, create a new class which inherits CCommandLineInfo. Then override ParseParam. Stability. What an interesting concept. -- Chris Maunder

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

        Thanks. lpCmdLine is a unsigned short *. The value i passed in the command line is just a BYTE (0-15). How can i convert lpCmdLine to a BYTE? Gunnar

        D 1 Reply Last reply
        0
        • G gunnar66

          Thanks. lpCmdLine is a unsigned short *. The value i passed in the command line is just a BYTE (0-15). How can i convert lpCmdLine to a BYTE? Gunnar

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

          Whether the command line contained one byte or several dozen, lpCmdLine is accessed in the same manner for each. It's simply a pointer to the command-line arguments.


          "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

          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