Firstly, I would like to say that I don't mean the full path, what
GetModuleFileName or argv[0] yield. Is there a smarter solution than dismissing everything before the last backslash?
First of all you want to get hold of the full path to the executable by calling GetModuleFileName
passing NULL
as the module handle. Then call PathFindFileName
to pull out the file name component.
There is in fact a difference between GetModuleFileName
and argv[0]
. The latter is the name used to start the process. It could be missing the full path, but more importantly here, it could be missing the .exe
extension. If you want to know the actual filename then you need to use GetModuleFileName
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With