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 exe running location

Get exe running location

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++visual-studio
8 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
    Johpoke
    wrote on last edited by
    #1

    There must be some nice simple function i can use to get the full directory location of where i am running my program from. Lets say my program is "me.exe" from "C:\WINDOWS\stuff\me.exe", then i want to get "C:\WINDOWS\stuff" or "C:\WINDOWS\stuff\" . My search failed so thats why im asking here, thanks :D edit: im in visual studio with a MFC dialog based application edit2: maybe i should add i want to find the full directory from the program itself, so it knows where its running from...

    //Johannes

    H 1 Reply Last reply
    0
    • J Johpoke

      There must be some nice simple function i can use to get the full directory location of where i am running my program from. Lets say my program is "me.exe" from "C:\WINDOWS\stuff\me.exe", then i want to get "C:\WINDOWS\stuff" or "C:\WINDOWS\stuff\" . My search failed so thats why im asking here, thanks :D edit: im in visual studio with a MFC dialog based application edit2: maybe i should add i want to find the full directory from the program itself, so it knows where its running from...

      //Johannes

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

      Do you need to GetModuleFileNameEx?


      WhiteSky


      J 1 Reply Last reply
      0
      • H Hamid Taebi

        Do you need to GetModuleFileNameEx?


        WhiteSky


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

        Is there something less hightech and more simple? Like none of the DWORD and all the other stuff (i edited my question abit)

        //Johannes

        H realJSOPR 2 Replies Last reply
        0
        • J Johpoke

          Is there something less hightech and more simple? Like none of the DWORD and all the other stuff (i edited my question abit)

          //Johannes

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

          If you want to find path of your program see GetModuleFileName and for get path of other process and also an example see Enumerating All Modules For a Process[^]


          WhiteSky


          J 1 Reply Last reply
          0
          • H Hamid Taebi

            If you want to find path of your program see GetModuleFileName and for get path of other process and also an example see Enumerating All Modules For a Process[^]


            WhiteSky


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

            Im using the code: TCHAR szPath[MAX_PATH]; GetModuleFileName(NULL,szPath,MAX_PATH); AfxMessageBox(szPath); however the messagebox show the full path and the executable name, i just want the full dir, thanks :)

            //Johannes

            J 1 Reply Last reply
            0
            • J Johpoke

              Im using the code: TCHAR szPath[MAX_PATH]; GetModuleFileName(NULL,szPath,MAX_PATH); AfxMessageBox(szPath); however the messagebox show the full path and the executable name, i just want the full dir, thanks :)

              //Johannes

              J Offline
              J Offline
              Johpoke
              wrote on last edited by
              #6

              if i use that in combination with PathRemoveFileSpec(szPath); it works :D thanks WhiteSky!

              //Johannes

              H 1 Reply Last reply
              0
              • J Johpoke

                Is there something less hightech and more simple? Like none of the DWORD and all the other stuff (i edited my question abit)

                //Johannes

                realJSOPR Offline
                realJSOPR Offline
                realJSOP
                wrote on last edited by
                #7

                Are you kidding? C++ too technical for ya? There's always VB...

                "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
                -----
                "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

                1 Reply Last reply
                0
                • J Johpoke

                  if i use that in combination with PathRemoveFileSpec(szPath); it works :D thanks WhiteSky!

                  //Johannes

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

                  I glad your problem solved.:-D


                  WhiteSky


                  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