Skip to content

Instantly share code, notes, and snippets.

@Jacob-Tate
Created February 8, 2020 04:53
Show Gist options
  • Save Jacob-Tate/81292ede52b7a2a7687171033876c9d4 to your computer and use it in GitHub Desktop.
Save Jacob-Tate/81292ede52b7a2a7687171033876c9d4 to your computer and use it in GitHub Desktop.
wchar_t path[FILENAME_MAX] = { 0 };
GetModuleFileName(nullptr, path, FILENAME_MAX);
// "C:\path1" "C:\"
// "C:\path1\path2" "C:\path1"
// "C:\path1\" "C:\path1"
// "\\path1\path2\path3" "\\path1\path2"
// "\path1" "\"
// This removed the exe from get module file name
// see: https://docs.microsoft.com/en-us/windows/win32/api/pathcch/nf-pathcch-pathcchremovefilespec
PathCchRemoveFileSpec(path, FILENAME_MAX);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment