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. How to get the parent proccess's path

How to get the parent proccess's path

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

    I want to run an application (see child) so that it can get the path of the current process (see parent). How?

    Thank you masters!

    S R B 3 Replies Last reply
    0
    • J Joseph Marzbani

      I want to run an application (see child) so that it can get the path of the current process (see parent). How?

      Thank you masters!

      S Offline
      S Offline
      Stephen Hewitt
      wrote on last edited by
      #2

      Your question is a little unclear. Why not simply pass the path to the process on the command line?

      Steve

      1 Reply Last reply
      0
      • J Joseph Marzbani

        I want to run an application (see child) so that it can get the path of the current process (see parent). How?

        Thank you masters!

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

        Are you looking for GetModuleFileName Function? You can get the path of the executable file of the current process using above function. Sample code:

        TCHAR szBuff[512];
        GetModuleFileName(0, szBuff, 512);

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

        1 Reply Last reply
        0
        • J Joseph Marzbani

          I want to run an application (see child) so that it can get the path of the current process (see parent). How?

          Thank you masters!

          B Offline
          B Offline
          Bram van Kampen
          wrote on last edited by
          #4

          Well, I would use GetModuleFileName() in the Parent process, and stuff it into the Environment of the Child Process:- PARENTPROCESS=C:\Program Files\etc... The Child Process can then queery the Environment, to get the Paren Process Name back. :)

          Bram van Kampen

          R 1 Reply Last reply
          0
          • B Bram van Kampen

            Well, I would use GetModuleFileName() in the Parent process, and stuff it into the Environment of the Child Process:- PARENTPROCESS=C:\Program Files\etc... The Child Process can then queery the Environment, to get the Paren Process Name back. :)

            Bram van Kampen

            R Offline
            R Offline
            raja jamwal
            wrote on last edited by
            #5

            Well you can use getcurrentdirectory to get the directory where the application was executed only if the parent process haven't changed that.

            B 1 Reply Last reply
            0
            • R raja jamwal

              Well you can use getcurrentdirectory to get the directory where the application was executed only if the parent process haven't changed that.

              B Offline
              B Offline
              Bram van Kampen
              wrote on last edited by
              #6

              raja jamwal wrote:

              Well you can use getcurrentdirectory to get the directory where the application was executed only if the parent process haven't changed that.

              No, Not Realy. getcurrentdirectory does exactly what it says. That is not nescessarily the same dir as where the exe is located. That's why I use GetModuleFileName(); :)

              Bram van Kampen

              R 1 Reply Last reply
              0
              • B Bram van Kampen

                raja jamwal wrote:

                Well you can use getcurrentdirectory to get the directory where the application was executed only if the parent process haven't changed that.

                No, Not Realy. getcurrentdirectory does exactly what it says. That is not nescessarily the same dir as where the exe is located. That's why I use GetModuleFileName(); :)

                Bram van Kampen

                R Offline
                R Offline
                raja jamwal
                wrote on last edited by
                #7

                yeah i know, the current directory variable attached with the module can be changed.

                B 1 Reply Last reply
                0
                • R raja jamwal

                  yeah i know, the current directory variable attached with the module can be changed.

                  B Offline
                  B Offline
                  Bram van Kampen
                  wrote on last edited by
                  #8

                  Amen :)

                  Bram van Kampen

                  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