Possible Duplicate:
Extracting the current executable name
I created a program that reads configuration from ini file, the name of that file should be identical to name of executable but of course with its extension. So If I name it myprogram.exe
the config should be myprogram.ini
, and if I change name of the exe after compilation it should look accorting to its new name.
I know that it is possible to get program name from argv[0]
but this works only if it starts from command line, when it is clicked in explorer this array is empty.
As I read through the answers here I think it has to do something with this function: https://stackoverflow.com/a/10572632/393087 - But I can't find any good example of usage of that function, I'm very beginner to c++ and general function definitions (like that presented on microsoft pages) are too hard for me to understand, but when I get a working example it is a snap for me to comprehend.