개발지식창고/MFC
[MFC]현제 프로그램이 실행되고 있는 디렉토리 구하기
모과이IT
2010. 9. 20. 14:12
std::string GetCurrentDirectory(void)
{
TCHAR curDir[1024];
TCHAR *RealDirEnd;
GetModuleFileName(NULL,curDir,1024);
RealDirEnd=_tcsrchr(curDir,_T('\\'));
RealDirEnd++;
*RealDirEnd=_T('\0');
CString path=curDir;
//---
CT2CA cvpath(path);
std::string s_path(cvpath);
//--
return s_path;
}
CString으로 리턴하려면 //-- 에서 --// 까지 지우고 path를 그대로 리턴하면 된다.