Win32 API - Getting The Program Name

I've been using this code so far:

1
2
3
4
5
6
7
char caExePath [MAX_PATH] = "", caExeName [100] = "";
GetModuleFileName (hInstance, caExePath, MAX_PATH);
int i = 0;
for (i = strlen (caExePath); caExePath [i] != '\\'; --i) continue;
++i;
for (int x = 0; caExePath [i] != '\0'; ++x, ++i) caExeName [x] = caExePath [i];
// Now caExeName holds the exe name. 


It works great but I was wondering if there was a better, "cleaner" way of getting the file name?

(When I say file I mean the name of the .exe file)
Last edited on
There is a GetModuleBaseName function.
MS has an API for it - I just forgot the name. Le t you know soon
_splitpath()
Topic archived. No new replies allowed.