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;
}