Possible Duplicate:
how to find the location of the executable in C
Hi,
I am looking for a portable way to find the root directory of a program (in C++). For instance, under Linux, a user could copy code to /opt, add it to the PATH, then execute it:
cp -r my_special_code /opt/
export PATH=${PATH}:/opt/my_special_code/
cd /home/tony/
execution_of_my_special_code
(where "execute_my_special_code" is the program in /opt/my_special_code).
Now, as a developer of "execution_of_my_special_code", is there a portable programmatical way of finding out that the executable is in /opt/my_special_code?
A second example is on MS Windows: What if my current working directory is on one hard drive (e.g. "C:\") and the executable is placed on another (e.g. "D:\")?
Ultimately, the goal is to read some predefined configuration files that are packaged with the program code without forcing the user to enter the installation directory.
Thanks a lot in advance!