I have to create a buffer to hold the the name of a license file which is in the executable directory. This is my klugy solution (I'm not a C programmer):
Code:
char buffer[MAX_PATH] = "";
GetModuleFileName(NULL, buffer, MAX_PATH);
int len = (int) strlen(buffer);
buffer[len-7] = '\0';
strcat(buffer,"license.lic");
Note I know the name of the executable is net.exe - 7 chars, so I'm cheating.
Firstly is this code safe? I got a compiler warning about using strcat saying I should use strcat_s, but I couldn't get that working.
Secondly how do I get the correct length of the executable name?