摘要:[MFC] MFC IO 處理
*擷取執行檔目錄
LPTSTR GetDir()
{
CString strAppName;
GetModuleFileName(NULL, strAppName.GetBuffer(_MAX_PATH), _MAX_PATH);
strAppName.ReleaseBuffer();
int nPos = strAppName.ReverseFind('\\');
strAppName = strAppName.Left(nPos + 1);
TCHAR tchBuffer[MAX_PATH ];
LPTSTR lpszCurDir;
lpszCurDir = tchBuffer;
GetCurrentDirectory(MAX_PATH , lpszCurDir);
return lpszCurDir;
}
*外部執行
CString _exePath,_para;
exePath="""";
_exePath+=(CString)GetDir() ;
_exePath+="\\123.exe";
_exePath+="""";
_para="""";
_para+=(CString)GetDir() ;
_para+="-xxx;
_para+="""";
ShellExecute(this->m_hWnd,_T("open"),_exePath,_para,NULL,SW_SHOW);
*MFC " 字串
如上例處理
CString="""";