vc获取程序的当前目录

	wchar_t wpath_buffer[_MAX_PATH];
	char drive[_MAX_DRIVE];
	char dir[_MAX_DIR];
	char fname[_MAX_FNAME];
	char ext[_MAX_EXT];

	GetModuleFileName(NULL, wpath_buffer, _MAX_PATH);
	char path_buffer[MAX_PATH]={0};
	w2c(wpath_buffer, path_buffer);
	_splitpath(path_buffer, drive, dir, fname, ext);
	CString strDir;
	strDir += drive;
	strDir += dir;
	AfxMessageBox(strDir);

 

你可能感兴趣的:(VC)