First of all, you want to get the full path to the executable file, calling GetModuleFileName, passing NULLas a module descriptor, then call PathFindFileNameto pull out the file name component.
In fact, there is a difference between GetModuleFileNameand argv[0]. The latter is the name used to start the process. This may not be the full path, but more importantly, there may be no extension .exe. If you want to know the actual file name, you need to use GetModuleFileName.
source
share