0

How I can get the executable path? Here I would like to take into consideration system native path representation.

I know it is possible using Qt, but it is not my choice this time. I have not found any possibilities of doing that with boost filesystem library. Any suggestions?

Yeah seem like duplicated, C++ development as usual impresses with its ability of making problems out of nothing.

Completely agree with Ben Hymers

So is this what everyone does whenever they want to find the executable's path in C++? I was hoping something as simple-sounding as this would already be implemented in a library like boost.

itun
  • 3,439
  • 12
  • 51
  • 75
  • DO you need it to be multiplatform? – Javi Nov 17 '14 at 04:13
  • An executable can have many paths. Presumably you want the one used to launch the executable. If you're not unlucky then that one can either be deduced from or is directly available as the zeroth argument of `main` or, in Windows, non-standard `wmain`. – Cheers and hth. - Alf Nov 17 '14 at 04:16

1 Answers1

1

For what operating system (or do you want an OS neutral solution)?

main/wmain are passed the .exe path in argv[0]. I'm not sure if there is an API to retrieve argv/argc some other way.

On Windows GetModuleFileName(nullptr, ...) will return the path to the currently running .exe.

Chris Guzak
  • 111
  • 6