Reputation: 2684
I have always used _pgmptr
, which was a char*
provided by Windows that gave the exact full path of the executable. However, after recently updating MinGW it seems to be defined to NULL instead. Is there any other way to get the full executable path, with out without its name (like instead of C:\program.exe
just C:\
would be okay for what I'm doing)?
I'm fine with a platform-independent way or Windows-specific way, as long as it is reliable.
Upvotes: 4
Views: 2988
Reputation: 354744
GetModuleFileName
is the API function to retrieve the program path and name.
Upvotes: 6