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 in Argvs in windows

Passing in Argvs in windows

Scheduled Pinned Locked Moved C / C++ / MFC
c++questionlearning
6 Posts 4 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.
  • U Offline
    U Offline
    Unplugged
    wrote on last edited by
    #1

    I know this is a really stupid question, but I'm use to programming on Unix systems. I wrote a program using MS Visual C++, and I want to pass in a value into the argsv. so I can run it at the command prompt something like: "whatever.exe filename.txt" of course this doesn't work. Any ideas? :confused: ICXC NIKA

    A J M 3 Replies Last reply
    0
    • U Unplugged

      I know this is a really stupid question, but I'm use to programming on Unix systems. I wrote a program using MS Visual C++, and I want to pass in a value into the argsv. so I can run it at the command prompt something like: "whatever.exe filename.txt" of course this doesn't work. Any ideas? :confused: ICXC NIKA

      A Offline
      A Offline
      Anders Molin
      wrote on last edited by
      #2

      Why doesn't it work, I have done that lots of times... Starting a program with "whatever.exe filename.txt" from the command promt I mean, and it works just fine. What exactly are you trying to do that don't work? - Anders Money talks, but all mine ever says is "Goodbye!"

      U 1 Reply Last reply
      0
      • A Anders Molin

        Why doesn't it work, I have done that lots of times... Starting a program with "whatever.exe filename.txt" from the command promt I mean, and it works just fine. What exactly are you trying to do that don't work? - Anders Money talks, but all mine ever says is "Goodbye!"

        U Offline
        U Offline
        Unplugged
        wrote on last edited by
        #3

        It works when I use the ms-dos command prompt. when I just go to start and run, then browse, then try to do it, it's a no go. :wtf: ICXC NIKA

        A 1 Reply Last reply
        0
        • U Unplugged

          It works when I use the ms-dos command prompt. when I just go to start and run, then browse, then try to do it, it's a no go. :wtf: ICXC NIKA

          A Offline
          A Offline
          Anders Molin
          wrote on last edited by
          #4

          You have to write "someprogram.exe" somefile.txt instead of "someprogram.exe somefile.txt" Then it works :-) - Anders Money talks, but all mine ever says is "Goodbye!"

          1 Reply Last reply
          0
          • U Unplugged

            I know this is a really stupid question, but I'm use to programming on Unix systems. I wrote a program using MS Visual C++, and I want to pass in a value into the argsv. so I can run it at the command prompt something like: "whatever.exe filename.txt" of course this doesn't work. Any ideas? :confused: ICXC NIKA

            J Offline
            J Offline
            Joaquin M Lopez Munoz
            wrote on last edited by
            #5

            I'm not sure whether this is what you're after, but in a Windows-based app you can use the variables __argc and __argv just as you did with the usual main parms in an Unix console program. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

            1 Reply Last reply
            0
            • U Unplugged

              I know this is a really stupid question, but I'm use to programming on Unix systems. I wrote a program using MS Visual C++, and I want to pass in a value into the argsv. so I can run it at the command prompt something like: "whatever.exe filename.txt" of course this doesn't work. Any ideas? :confused: ICXC NIKA

              M Offline
              M Offline
              Michael Dunn
              wrote on last edited by
              #6

              WinMain(), as you've seen, doesn't have the argc/argv params. You can access them via the lpCmdLine parameter to WinMain(). Alternatively, there are __argc and __argv variables that the CRT sets up for you that work like argc/argv. --Mike-- Just released - RightClick-Encrypt - Adds fast & easy file encryption to Explorer My really out-of-date homepage Sonork-100.19012 Acid_Helm

              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