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. path to executable

path to executable

Scheduled Pinned Locked Moved C / C++ / MFC
8 Posts 5 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.
  • S Offline
    S Offline
    SAK
    wrote on last edited by
    #1

    I am programming in c and would like to know how I can find the location of my executable programatically. So if the executable is moved to a new location my program will know its current path. Thanks, SAK

    V T D 3 Replies Last reply
    0
    • S SAK

      I am programming in c and would like to know how I can find the location of my executable programatically. So if the executable is moved to a new location my program will know its current path. Thanks, SAK

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

      One solution is GetModuleFileName(). Another solution is GetCurrentDirectory(). Kuphryn

      S 1 Reply Last reply
      0
      • S SAK

        I am programming in c and would like to know how I can find the location of my executable programatically. So if the executable is moved to a new location my program will know its current path. Thanks, SAK

        T Offline
        T Offline
        Ted Ferenc
        wrote on last edited by
        #3

        To parapahrase "If all else fails read the FAQ" http://www.codeproject.com/cpp/cppforumfaq.asp[^]


        If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676

        S 1 Reply Last reply
        0
        • T Ted Ferenc

          To parapahrase "If all else fails read the FAQ" http://www.codeproject.com/cpp/cppforumfaq.asp[^]


          If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676

          S Offline
          S Offline
          SAK
          wrote on last edited by
          #4

          Thanks for the help...much appreciated. SAK

          1 Reply Last reply
          0
          • S SAK

            I am programming in c and would like to know how I can find the location of my executable programatically. So if the executable is moved to a new location my program will know its current path. Thanks, SAK

            D Offline
            D Offline
            Dean Goodman
            wrote on last edited by
            #5

            If you are just writing a simple console app, you can use argv[0]. --Dean

            S 1 Reply Last reply
            0
            • V valikac

              One solution is GetModuleFileName(). Another solution is GetCurrentDirectory(). Kuphryn

              S Offline
              S Offline
              SAK
              wrote on last edited by
              #6

              Kuphryn, This is exactly what I was looking for. Thank you

              1 Reply Last reply
              0
              • D Dean Goodman

                If you are just writing a simple console app, you can use argv[0]. --Dean

                S Offline
                S Offline
                SAK
                wrote on last edited by
                #7

                Dean, Good information...Thanks

                P 1 Reply Last reply
                0
                • S SAK

                  Dean, Good information...Thanks

                  P Offline
                  P Offline
                  Peter Weyzen
                  wrote on last edited by
                  #8

                  Except -- argv[0] does not return a fully-qualified path name if the .EXE is run from the same directory (from the current directory). ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Peter Weyzen Staff Engineer Santa Cruz Networks

                  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