잠토의 잠망경

GetMoudleFileName & _splitpath 실행파일의 경로와 경로에서 필요한 부분 얻기 본문

공부/API

GetMoudleFileName & _splitpath 실행파일의 경로와 경로에서 필요한 부분 얻기

잠수함토끼 2008. 9. 9. 09:48
#undef UNICODE

#include 
#include 


void ProcB()
{
	CHAR str[128]={0,};
	//프로세스의 파일 이름을 출력합니다.
	GetModuleFileName(NULL,str,128);
	printf(str);
	printf("\n\n");
	CHAR drive[_MAX_DRIVE]={0,};
	char dir[_MAX_DIR]={0,};
	char fname[_MAX_FNAME]={0,};
	char ext[_MAX_EXT]={0,};
	
	//http://www.winapi.co.kr/clec/cpp2/17-4-3.htm
	//한개의 입력 경로를 각 부분에 맞게 버퍼에 넣어준다.
	//예를 들어c:\\My Document\\Test\\Report 2.5.bak 같은경우
	// drive:	c:
	// dir:		\\My Document\\Test\\
	// fname:	Report 2.5
	// ext	:	.bak
	_splitpath(str,drive,dir,fname,ext);

	printf(drive);
	printf("\n");
	printf(dir);
	printf("\n");
	printf(fname);
	printf("\n");
	printf(ext);
	printf("\n");
}


int main(void)
{
	ProcB();
	return 0;
}
Comments