MFC/MFC 코드기록

실행 파일이 있는 현재 경로 구하는 코드

lwj789 2024. 1. 3. 10:57
wchar_t chFilePath[256] = { 0, };
GetModuleFileName(NULL, chFilePath, 256);
CString strFolderPath(chFilePath);
strFolderPath = strFolderPath.Left(strFolderPath.ReverseFind('\\'));
strFolderPath.Format(L"%s\\config\\script.txt", strFolderPath); // L"C:\\Users\\PC\\Desktop\\release\\config\\script.txt";