취미 기록용 블로그

현재 실행 경로 가져오기

자주 쓰는 기능인데 할때 마다 예전에 만든 소스 찾는거 귀찮아서 여기에 정리한다.

wchar_t CurrentTempDIR[_MAX_PATH];
GetModuleFileNameW(NULL,CurrentTempDIR,_MAX_PATH);
std::wstring strCurrentPath = CurrentTempDIR;
std::wstring::size_type tmpPost;
tmpPost =strCurrentPath.rfind(L"\\",strCurrentPath.size());
strCurrentPath = strCurrentPath.substr(0, tmpPost);

이건 유니코드 버전

char CurrentTempDIR[_MAX_PATH];
GetModuleFileNameA(NULL,CurrentTempDIR,_MAX_PATH);
std::string strCurrentPath = CurrentTempDIR;
std::string::size_type tmpPost;
tmpPost =strCurrentPath.rfind("\\",strCurrentPath.size());
strCurrentPath = strCurrentPath.substr(0, tmpPost);

요건 ANSI 버전


Comments

답글 남기기

이메일 주소는 공개되지 않습니다. (이름과 이메일은 안써도 됩니다)

이 사이트는 Akismet을 사용하여 스팸을 줄입니다. 댓글 데이터가 어떻게 처리되는지 알아보세요.