VC++ 6.0
2012.05.07 11:06
현재폴더경로 구하는 함수
경훈 주소복사
조회 수 3712 추천 수 0 댓글 1
구분 | 팁&트릭 |
---|
변경 전 : GetCurrentDirectory(MAX_PATH, cCurPath);
변경 후 : GetModuleFileName(NULL, szPath, MAX_PATH )를 이용하여 구하기
변경 이유 : GetCurrentDirectory()로 구할 시 프로그램 내에 CFileDialog() 함수 호출 시 PATH가 변경됨
GetModuleFileName() 함수의 경우 실행되는 프로그램의 경로 및 실행 파일 명을 가져 오는 함수이다.
( C:\TEST\TEST.EXE 형식을 구해진다)
아래와 같이 변경
char szPath[ MAX_PATH];
memset(szPath,NULL, sizeof(szPath));
GetModuleFileName(NULL, szPath, MAX_PATH);
CString strTemp = _T("");
strTemp.Format("%s", szPath);
int nReverFind = -1;
nReverFind = strTemp.ReverseFind('\\');
SetSkinPath(strTemp.Left(nReverFind));
memset(szPath,NULL, sizeof(szPath));
GetModuleFileName(NULL, szPath, MAX_PATH);
CString strTemp = _T("");
strTemp.Format("%s", szPath);
int nReverFind = -1;
nReverFind = strTemp.ReverseFind('\\');
SetSkinPath(strTemp.Left(nReverFind));
char szValue[256] = { 0 };
GetModuleFileName(AfxGetInstanceHandle(), strTemp.GetBufferSetLength(_MAX_PATH),_MAX_PATH);
int nFind = strTemp.ReverseFind('\\');
strConfigPath2 = strTemp.Left(nFind)