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. passing an argument to an executable file

passing an argument to an executable file

Scheduled Pinned Locked Moved C / C++ / MFC
questionlearning
5 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.
  • J Offline
    J Offline
    JCY
    wrote on last edited by
    #1

    Just an inquiry... How do I implement my program so that if I made it an executable file, it's possible to pass "arguments/parameters" to the executable file when it is called... i.e. if I made my BOOk Program as an executable file and I want my executable file of the Book program to accept video file parameters, how do I do this? In analogy, if i want to open the realplayer.Exe, i command a SHELLEXECUTE with the *.rm file as paramenter and the realplayer automatically opens it. Thanks in Advance. Best Wishes to all.

    C R 2 Replies Last reply
    0
    • J JCY

      Just an inquiry... How do I implement my program so that if I made it an executable file, it's possible to pass "arguments/parameters" to the executable file when it is called... i.e. if I made my BOOk Program as an executable file and I want my executable file of the Book program to accept video file parameters, how do I do this? In analogy, if i want to open the realplayer.Exe, i command a SHELLEXECUTE with the *.rm file as paramenter and the realplayer automatically opens it. Thanks in Advance. Best Wishes to all.

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      pass the parameters on the command line: c:\> MyApp.EXE file.ext in your app, use one of the many command line parsers available here to grab the parameters and act accordingly. -c


      Smaller Animals Software, Inc.

      J 1 Reply Last reply
      0
      • C Chris Losinger

        pass the parameters on the command line: c:\> MyApp.EXE file.ext in your app, use one of the many command line parsers available here to grab the parameters and act accordingly. -c


        Smaller Animals Software, Inc.

        J Offline
        J Offline
        JCY
        wrote on last edited by
        #3

        Sorry, u might have misunderstood my question 'cuz it seems a little bit confusing... to clarify: I'll set an example. I have two programs: "X" and "Y" program. -I programmed X to process video files. then convert it to executable file -I have another program Y which calls this executable file of X (X.exe) with a VIDEO FILE parameter possibly using the command ShellExecute (hwnd, "open", "X.exe", [Video File PathName], [Directory of Executable File], SW_SHOWNORMAL); so the question is, how do i Program X so that it can accept the VIDEO FILE parameter of Y. and open it afterwards. Y ---video file ---> X.exe Thanks in Advance... :)

        1 Reply Last reply
        0
        • J JCY

          Just an inquiry... How do I implement my program so that if I made it an executable file, it's possible to pass "arguments/parameters" to the executable file when it is called... i.e. if I made my BOOk Program as an executable file and I want my executable file of the Book program to accept video file parameters, how do I do this? In analogy, if i want to open the realplayer.Exe, i command a SHELLEXECUTE with the *.rm file as paramenter and the realplayer automatically opens it. Thanks in Advance. Best Wishes to all.

          R Offline
          R Offline
          Rick Crone
          wrote on last edited by
          #4

          The command line parameters can be used in the InitInstance() of your application. The command line is stored in m_lpCmdLine which is a char array. If you pass your parameter with a slash (ie. /MYPARM) they will be considered flags. If you don't include the slash the first parameter will be considered to be the file you want to open. You can turn off that behavior my setting: cmdIndo.mShellCommand = CCommandLineInfo::FileNew; but why not just include the slash? *NOTE you can test your command line parameter in the developer studio! see the PROJECT - SETTINGS - DEBUG(tab) I usually deal with the command line in my applications InitInstance() just before: // Parse command line for standard shell commands, DDE, file open CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo);

          J 1 Reply Last reply
          0
          • R Rick Crone

            The command line parameters can be used in the InitInstance() of your application. The command line is stored in m_lpCmdLine which is a char array. If you pass your parameter with a slash (ie. /MYPARM) they will be considered flags. If you don't include the slash the first parameter will be considered to be the file you want to open. You can turn off that behavior my setting: cmdIndo.mShellCommand = CCommandLineInfo::FileNew; but why not just include the slash? *NOTE you can test your command line parameter in the developer studio! see the PROJECT - SETTINGS - DEBUG(tab) I usually deal with the command line in my applications InitInstance() just before: // Parse command line for standard shell commands, DDE, file open CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo);

            J Offline
            J Offline
            JCY
            wrote on last edited by
            #5

            Thanks a lot .. I'll try to implement your suggestion. :)

            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