Finding the path of an .exe file

This is a discussion on Finding the path of an .exe file within the C Programming forums, part of the General Programming Boards category; I would like to know how to find out what the directory path of a running program is. The intention ...

  1. #1
    Registered User Gonzo's Avatar
    Join Date
    Sep 2003
    Posts
    5

    Question Finding the path of an .exe file

    I would like to know how to find out what the directory path of a running program is.

    The intention being, that if I distrubute a small zipped program to some friends with a preset file and folder structure for the program to save files too, how can I get the program to find out where it has been unzipped too (because once I know the path to the .exe file I can access the folder structure unzipped with it.


    I'm not sure if I've explained this right, or even if the scenario I've given is quite right, but if anyone has any ideas or thinks they might have something that is applicable to this, please let me know.

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    http://www.eskimo.com/~scs/C-faq/q19.32.html

    The problem is the argv[0] isn't guaranteed to be correct, the current working directory isn't necessarily where the .exe is, and there aren't any standard C functions to find the .exe. You might find your compilers documentation more helpful (an MS example ).
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File Writing Problem
    By polskash in forum C Programming
    Replies: 3
    Last Post: 02-13-2009, 09:47 AM
  2. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  3. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 01:53 AM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21