Retrieving the current executable file name

First, I would like to say that I do not mean the full path, that GetModuleFileName or argv [0]. Is there a smarter solution than firing everything to the last backslash?

+4
source share
3 answers

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.

+16
source

If you are using .NET, here is the answer. But internally it can be a challenge GetModuleFileName.

0
source

Windows C/C++ extern char * _pgmptr, , _get_pgmptr(char ** buffer).

_get_pgmptr() , , main() WinMain(). _pgmptr , . . _pgmptr, _wpgmptr.

DLL , .

_pgmptr .

0

All Articles