使用了cstring void GetCurrentPath(char *pPath) { CString strPath; //get entire path of running application and its title GetModuleFileName(NULL,pPath,MAX_PATH); strPath.Format(pPath); int iPos=strPath.ReverseFind('//'); if ((unsigned)iPos == -1) { return ; } memset(pPath, 0, MAX_PATH); strncpy(pPath, strPath.Left(iPos).GetBuffer(0), iPos); pPath[iPos]='/0'; }