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. get path of current application C++

get path of current application C++

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
12 Posts 7 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.
  • A arbster

    How would I get the full path of where an application is saved and started from in a C++ application??:)

    R Offline
    R Offline
    Rajesh R Subramanian
    wrote on last edited by
    #2

    User GetCurrentDirectory()


    Nobody can give you wiser advice than yourself. - Cicero ப்ரம்மா

    2 1 Reply Last reply
    0
    • A arbster

      How would I get the full path of where an application is saved and started from in a C++ application??:)

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #3

      Some times what you need is GetModuleFileName. :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

      In testa che avete, signor di Ceprano?

      1 Reply Last reply
      0
      • A arbster

        How would I get the full path of where an application is saved and started from in a C++ application??:)

        H Offline
        H Offline
        Hamid Taebi
        wrote on last edited by
        #4

        Wheres this program when you run your project or when a program is running?


        WhiteSky


        1 Reply Last reply
        0
        • R Rajesh R Subramanian

          User GetCurrentDirectory()


          Nobody can give you wiser advice than yourself. - Cicero ப்ரம்மா

          2 Offline
          2 Offline
          224917
          wrote on last edited by
          #5

          GetCurrentDirectory can be different many times, like depending on the parent process currentdirectory, or "Startin Folder" of a short cut or how setcurrentdirectory() etc

          R 1 Reply Last reply
          0
          • 2 224917

            GetCurrentDirectory can be different many times, like depending on the parent process currentdirectory, or "Startin Folder" of a short cut or how setcurrentdirectory() etc

            R Offline
            R Offline
            Rajesh R Subramanian
            wrote on last edited by
            #6

            And why do you say this to me?


            Nobody can give you wiser advice than yourself. - Cicero ப்ரம்மா

            2 1 Reply Last reply
            0
            • R Rajesh R Subramanian

              And why do you say this to me?


              Nobody can give you wiser advice than yourself. - Cicero ப்ரம்மா

              2 Offline
              2 Offline
              224917
              wrote on last edited by
              #7

              brahmma wrote:

              And why do you say this to me?

              You suggested to use GetCurrentDirectory() for retrieving the application path.

              R 1 Reply Last reply
              0
              • A arbster

                How would I get the full path of where an application is saved and started from in a C++ application??:)

                C Offline
                C Offline
                Cristian Amarie
                wrote on last edited by
                #8

                I don't understand what means "path where application is saved". If what you need is the folder from where application was started, use GetModuleFileName(NULL) or GetCommandLine to retrieve the full exe path and then PathRemoveFileSpec to get only the path. GetCurrentDirectory can be altered during program execution (not to mention that the application itself can be configured to run in other directory than the directory where the application resides).

                1 Reply Last reply
                0
                • A arbster

                  How would I get the full path of where an application is saved and started from in a C++ application??:)

                  S Offline
                  S Offline
                  Sumesh V V
                  wrote on last edited by
                  #9

                  To get complete path of the current application.... TCHAR szPath[MAX_PATH]; GetModuleFileName(AfxGetApp()->m_hInstance, szPath, MAX_PATH); Use CreateProcess() to start an application. :)

                  1 Reply Last reply
                  0
                  • 2 224917

                    brahmma wrote:

                    And why do you say this to me?

                    You suggested to use GetCurrentDirectory() for retrieving the application path.

                    R Offline
                    R Offline
                    Rajesh R Subramanian
                    wrote on last edited by
                    #10

                    The question itself is not very clear. See here[^] And so did I suggest GetCurrentDirectory(). If you were *of any help* to the person who asked the question, go tell him what you know.


                    Nobody can give you wiser advice than yourself. - Cicero ப்ரம்மா

                    2 1 Reply Last reply
                    0
                    • R Rajesh R Subramanian

                      The question itself is not very clear. See here[^] And so did I suggest GetCurrentDirectory(). If you were *of any help* to the person who asked the question, go tell him what you know.


                      Nobody can give you wiser advice than yourself. - Cicero ப்ரம்மா

                      2 Offline
                      2 Offline
                      224917
                      wrote on last edited by
                      #11

                      brahmma wrote:

                      The question itself is not very clear. See here[^] And so did I suggest GetCurrentDirectory().

                      Whichever way you interpret the question, your answer would not work. Do not expect to getaway after posting wrong answers in public forums.

                      brahmma wrote:

                      If you were *of any help* to the person who asked the question, go tell him what you know.

                      The right answer was already posted and voted see here [^] so i did not want to repeat the same answer.

                      R 1 Reply Last reply
                      0
                      • 2 224917

                        brahmma wrote:

                        The question itself is not very clear. See here[^] And so did I suggest GetCurrentDirectory().

                        Whichever way you interpret the question, your answer would not work. Do not expect to getaway after posting wrong answers in public forums.

                        brahmma wrote:

                        If you were *of any help* to the person who asked the question, go tell him what you know.

                        The right answer was already posted and voted see here [^] so i did not want to repeat the same answer.

                        R Offline
                        R Offline
                        Rajesh R Subramanian
                        wrote on last edited by
                        #12

                        suhredayan® wrote:

                        Whichever way you interpret the question, your answer would not work.

                        Huh? GetCurrentDirectory() does return the current directory. I have not suggested anything wrong. GetCurrentDirectory or GetModuleFileName, or even something else; depending on the user's need he has to choose what he wants.


                        Nobody can give you wiser advice than yourself. - Cicero ப்ரம்மா

                        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