Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get Executable directory

Status
Not open for further replies.

Beard36

Programmer
Sep 4, 2003
69
GB
Just a quick question:

My application reads in an INI file that it needs to access, which is found in the same folder as the executable itself. I used to have the folder name for the executable (and so the INI file) hardcode into the source, but I'd prefer the flexibility of locating the program and its data file in ANY folder.

I tried using the curdir function. This seemed to work fine when I launched it from explorer. However, if I call it from the command line (eg. P:\folder\MyApp.exe) then curdir picks up the folder I'm currently in, not P:\folder as I'd like.

So, is there an function similar to curdir which instead identifies the directory in which the executable resides?

I've been having a look round the 'net, but no joy yet.

Any help would be much appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top