vc获取特殊路径

//c:/windows/system32
CString FileUtil::GetSystem32Dir() {
	CString strPath;
	::GetSystemDirectory(strPath.GetBuffer(_MAX_PATH), _MAX_PATH);
	strPath.ReleaseBuffer();
	MessageBox(NULL,LPCTSTR(strPath), "SysPath", MB_OK);

	return strPath;
}

//C:\Program Files
CString  FileUtil::GetProgarmeFile() {
	CString sPath;

	SHGetFolderPath(NULL, CSIDL_PROGRAM_FILES, NULL, 0, sPath.GetBuffer(MAX_PATH));

	sPath.ReleaseBuffer();

	return sPath;
}

//<user name>\Local Settings\Applicaiton Data (non roaming)
CString  FileUtil::GetAPPLocal() {
	CString sPath;

	SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, sPath.GetBuffer(MAX_PATH));

	sPath.ReleaseBuffer();

	return sPath;
}


posted @ 2021-09-08 11:50  Hey,Coder!  阅读(50)  评论(0编辑  收藏  举报