Programming Tips - Win32: Get program filename

Date: 2020may28 Language: C/C++ Platform: win32 OS: Windows Q. Win32: Get program filename A.
void GetProgramFilename(LPTSTR szExe, const size_t size) { GetModuleFileName(GetModuleHandle(NULL), szExe, size); } void ExampleUse() { char szExe[MAX_PATH]; GetProgramFilename(szExe, sizeof(szExe)); printf("This is %s\n", szExe); }