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

Path

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestion
8 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.
  • J Offline
    J Offline
    john5632
    wrote on last edited by
    #1

    How to get current application path in C++?

    _ L P R Y 5 Replies Last reply
    0
    • J john5632

      How to get current application path in C++?

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      In Windows, it is GetCurrentDirectory.

      «_Superman_»
      I love work. It gives me something to do between weekends.

      Microsoft MVP (Visual C++)

      Polymorphism in C

      1 Reply Last reply
      0
      • J john5632

        How to get current application path in C++?

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        AFAIK, the C++ language itself doesn't provide such functionality. And neither does any of the C runtime libraries (someone correct me if I am wrong). You have to use the underlying OS's (or any runtime environment's) APIs to achieve that. For Windows, Superman's reply holds.

        ...byte till it megahertz...

        K 1 Reply Last reply
        0
        • L Lost User

          AFAIK, the C++ language itself doesn't provide such functionality. And neither does any of the C runtime libraries (someone correct me if I am wrong). You have to use the underlying OS's (or any runtime environment's) APIs to achieve that. For Windows, Superman's reply holds.

          ...byte till it megahertz...

          K Offline
          K Offline
          kakan
          wrote on last edited by
          #4

          What about getcwd() / _getcwd()? Declared in direct.h or unistd.h for Unix But for question the OP: GetModuleFileName() returns the fully qualified path of the application.

          Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson

          L 1 Reply Last reply
          0
          • K kakan

            What about getcwd() / _getcwd()? Declared in direct.h or unistd.h for Unix But for question the OP: GetModuleFileName() returns the fully qualified path of the application.

            Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            kakan wrote:

            What about getcwd() / _getcwd()? Declared in direct.h or unistd.h for Unix

            :doh: Oh YEAH! :-O Thanks! direct.h is in Windows too.

            ...byte till it megahertz...

            1 Reply Last reply
            0
            • J john5632

              How to get current application path in C++?

              P Offline
              P Offline
              Paul Michalik
              wrote on last edited by
              #6

              If you are targeting different platforms, I heartily recommend to use boost::filesystem which abstracts this functionality in a very comfortable manner. If only one platform is targeted and this platform is windows, use designated Microsoft frameworks instead of this low level APIs.

              1 Reply Last reply
              0
              • J john5632

                How to get current application path in C++?

                R Offline
                R Offline
                rp_suman
                wrote on last edited by
                #7

                by googling[^] you can get most of the answers without posting it again and can save time.

                -- "Programming is an art that fights back!"

                1 Reply Last reply
                0
                • J john5632

                  How to get current application path in C++?

                  Y Offline
                  Y Offline
                  yu jian
                  wrote on last edited by
                  #8

                  void CGetCurrentDirectoryDlg::OnBnClickedOk() { TCHAR tcPathName[100]; GetCurrentDirectory(100, tcPathName); }

                  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