MFC 获取当前工作路径和可执行文件路径
作者:互联网
1. 获取Debug或Release所在的路径 可执行文件路径
CString GetModuleDir()
{
HMODULE module = GetModuleHandle(0);
char pFileName[MAX_PATH];
GetModuleFileName(module, pFileName, MAX_PATH);
CString csFullPath(pFileName);
int nPos = csFullPath.ReverseFind( _T('\\') );
if( nPos < 0 )
return CString("");
else
return csFullPath.Left( nPos );
}
2. 获取当前工作路径(dsp所在路径)
//获取工作路径
CString GetWorkDir()
{
char pFileName[MAX_PATH];
int nPos = GetCurrentDirectory( MAX_PATH, pFileName);
CString csFullPath(pFileName);
if( nPos < 0 )
return CString("");
else
return csFullPath;
}
标签:可执行文件,MFC,csFullPath,路径,nPos,PATH,CString,pFileName 来源: https://blog.csdn.net/u011555996/article/details/90733771