Thread: Startup path.

  1. #1
    Registered Viking
    Join Date
    Aug 2006
    Location
    Norway
    Posts
    19

    Startup path.

    Greetings.

    Google wouldn't find me an answear so I thought I'd ask you guys

    Using c++, i need to get the path my console app runs from.
    Now, I know a lot of you are thinking: just supply the filename relative to your executeable, and you're allright!

    E.g.
    Code:
    filename = "file.ext";
    However, I wouldn't be, because if you launch the program from another dir than the one containing the executeable (e.g. toolbar, shortcut etc.), the working directory would be incorrect. (At least it does in windows);
    Thusly, I require something like this:
    Code:
    filename = get_startup_path() + "\\filename.ext";
    So, if anyone has an answear I'd be very, very thankful.

    Regards,
    MisterT
    Last edited by MisterT; 12-26-2006 at 06:50 AM.

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    argv[0] ?
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Since you've posted on the Windows board GetModuleFileName might be of interest.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  4. #4
    Registered Viking
    Join Date
    Aug 2006
    Location
    Norway
    Posts
    19
    Thanks a lot!
    Sorry about posting in the Windows forum,
    I'm kinda new here..

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Shortest Path Maze Solver (Breadth Search Help)
    By Raskalnikov in forum C Programming
    Replies: 5
    Last Post: 04-07-2009, 07:41 PM
  2. clipping path
    By stanlvw in forum Windows Programming
    Replies: 0
    Last Post: 07-23-2008, 11:47 PM
  3. Shortest path problem
    By Digitalxero in forum C++ Programming
    Replies: 0
    Last Post: 10-25-2005, 05:32 PM
  4. Path Finding Using Adjacency List.
    By Geolingo in forum C++ Programming
    Replies: 7
    Last Post: 05-16-2005, 02:34 PM
  5. linked list recursive function spaghetti
    By ... in forum C++ Programming
    Replies: 4
    Last Post: 09-02-2003, 02:53 PM