【1】AfxGetApp
CString strPath = AfxGetApp()->m_pszExeName;
CString strCurrentDir = strPath.Left(strPath.ReverseFind('\\'));
问题:如果是在dll调用此函数,则strPath返回dll名称
【2】strPath返回应用程序全路径
TCHAR szPath[MAX_PATH];
GetModuleFileName(NULL, szPath, MAX_PATH);
CString strPath = szPath;
CString strCurrentDir = strPath.Left(strPath.ReverseFind('\\'));
【3】GetCurrentDirectory
TCHAR szPath[MAX_PATH];
GetCurrentDirectory(MAX_PATH, szPath);
CString strCurrentDir = szPath;
问题:获取当前目录,但是不一定是应用程序目录