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. Need GetModuleFileName for UNIX.

Need GetModuleFileName for UNIX.

Scheduled Pinned Locked Moved C / C++ / MFC
c++questionlearning
3 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.
  • A Offline
    A Offline
    Alvaro Mendez
    wrote on last edited by
    #1

    I'm writing a C++ console app for Windows and UNIX. When it runs, the app needs to know the directory where it's located. Of course, this may or may not be different from the working directory (which I don't care about). I need the directory where the app's file is at -- the equivalent of GetModuleFileName on Windows. Anyone have a clue? :confused: Thanks, Alvaro

    R J 2 Replies Last reply
    0
    • A Alvaro Mendez

      I'm writing a C++ console app for Windows and UNIX. When it runs, the app needs to know the directory where it's located. Of course, this may or may not be different from the working directory (which I don't care about). I need the directory where the app's file is at -- the equivalent of GetModuleFileName on Windows. Anyone have a clue? :confused: Thanks, Alvaro

      R Offline
      R Offline
      Roger Scudder
      wrote on last edited by
      #2

      There are many flavors of UNIX. You will need to look at the system calls available for the flavor you are coding for.

      1 Reply Last reply
      0
      • A Alvaro Mendez

        I'm writing a C++ console app for Windows and UNIX. When it runs, the app needs to know the directory where it's located. Of course, this may or may not be different from the working directory (which I don't care about). I need the directory where the app's file is at -- the equivalent of GetModuleFileName on Windows. Anyone have a clue? :confused: Thanks, Alvaro

        J Offline
        J Offline
        James R Twine
        wrote on last edited by
        #3

        > When it runs, the app needs to know the directory where it's located. Check the first argument passed to "main(...)". That usually contains the path to the executable. -=- James.

        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