Page 2 of 2

Re: Getting the directory of executable (like GetModuleFileN

Posted: Mon Jun 18, 2012 5:23 am
by MicroVirus
Thanks for your responses.
edgar-rft wrote:It's generally not desirable to have a function returning the location of the executable, because this opens the door and invites all virii of the internet to manipulate the executable.
I don't understand what you mean with this. Any Windows executable can get its own location using GetModuleFileName or from another process it can access with query rights using GetModuleFileNameEx. Finally, any virus could easily search the system for *.exe files. So, I'm guessing I didn't understand what you meant here.

I know about the 'proper' location for config files; it's just that this is a little project which will be used by me and a friend where the config file will have to be manually edited, so for ease of use I'd like it in the same directory, like the old-school INI files.

I'm thinking about simply requiring the current working directory to be set properly before opening the program. Probably easiest.