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. Program Startup Folder

Program Startup Folder

Scheduled Pinned Locked Moved C / C++ / MFC
questionwindows-adminsecurity
5 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.
  • E Offline
    E Offline
    Eurosid
    wrote on last edited by
    #1

    How can I determine the folder where the .exe file is saved? I must do this without the registry due to goofy security restrictions on the PC where this app will run.

    B M 2 Replies Last reply
    0
    • E Eurosid

      How can I determine the folder where the .exe file is saved? I must do this without the registry due to goofy security restrictions on the PC where this app will run.

      B Offline
      B Offline
      BadJerry
      wrote on last edited by
      #2

      TCHAR lpszPath[MAX_PATH] = {0}; DWORD dwResult = ::GetModuleFileName(AfxGetInstanceHandle(), lpszPath, MAX_PATH);

      E 1 Reply Last reply
      0
      • B BadJerry

        TCHAR lpszPath[MAX_PATH] = {0}; DWORD dwResult = ::GetModuleFileName(AfxGetInstanceHandle(), lpszPath, MAX_PATH);

        E Offline
        E Offline
        Eurosid
        wrote on last edited by
        #3

        Thank you!!! :) That does exactly what I need.

        1 Reply Last reply
        0
        • E Eurosid

          How can I determine the folder where the .exe file is saved? I must do this without the registry due to goofy security restrictions on the PC where this app will run.

          M Offline
          M Offline
          Michael Dunn
          wrote on last edited by
          #4

          You're asking for two different things there. I take "startup folder" to mean the "current directory" of the process, which doesn't have to be the same as the dir where the EXE is. If you want the current directory, call GetCurrentDirectory(). --Mike-- LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ Strange things are afoot at the U+004B U+20DD

          E 1 Reply Last reply
          0
          • M Michael Dunn

            You're asking for two different things there. I take "startup folder" to mean the "current directory" of the process, which doesn't have to be the same as the dir where the EXE is. If you want the current directory, call GetCurrentDirectory(). --Mike-- LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ Strange things are afoot at the U+004B U+20DD

            E Offline
            E Offline
            Eurosid
            wrote on last edited by
            #5

            That works too, thanks.

            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