strrchr()函数头文件: string.h
CString xxxDlg::GetExePath()
{
CString strPath;
// 获取路径
char pszFilePath[MAX_PATH];
memset(pszFilePath, 0 , sizeof(pszFilePath) * sizeof(char));
GetModuleFileName(NULL, pszFilePath, MAX_PATH);
// 去除末尾的"\xxx.exe"
char *pPos = NULL;
pPos = strrchr(pszFilePath, '\\');
*pPos = NULL;
// 给末尾添加上"\"
if (pszFilePath[strlen(pszFilePath)-1] != '\\')
strcat(pszFilePath, "\\");
strPath.Format(_T("%s"), pszFilePath);
return strPath;
}