char exe_path[MAX_PATH]; if (DWORD len = GetModuleFileName(NULL, exe_path, sizeof(exe_path)/sizeof(exe_path[0]))) { // removing the filename of the exe, leaving there just the directory part... while (len>0 && exe_path[len-1]!='\\') --len; exe_path[len] = 0; // now exe_path holds the directory that contains the exe file with a trailing backslash strcat(exe_path, "myfile.txt"); // blah blah blah }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)