The path and name of the executable file are stored in the first command line argument array entry that is passed to the main function. So you may copy that or store a pointer.
Alternatively you can use the
GetModuleFileName()[
^] function:
TCHAR path[MAX_PATH];
GetModuleFileName(GetModuleHandle(NULL), path, MAX_PATH);
LPCTSTR ext = _tcsrchr(path, _T('\\'));
if (ext)
ext[1] = _T('\0');