同上

解决方案 »

  1.   

    看看strrchr函数的用法,可参见CString::ReverseFind()函数
      

  2.   

    比如:
    在C:\\temp\\test.txt找到test.txt
    int pos;
    pos=m_sApp.ReverseFind('\\');
    CString path=m_sApp.Left(pos);
    CString title=m_sApp.Right(strlen(m_sApp)-pos);
    tltle就是test.txt了
      

  3.   

    这是一个记事本查找字符串的片断
    BOOL PopFindFindText (HWND hwndEdit, int * piSearchOffset, LPFINDREPLACE pfr)
    {
         int    iLength, iPos ;
         PTSTR  pstrDoc, pstrPos ;
         
              // 读入编辑的文本
         
         iLength = GetWindowTextLength (hwndEdit) ;
         
         if (NULL == (pstrDoc = (PTSTR) malloc ((iLength + 1) * sizeof (TCHAR))))
              return FALSE ;
         
         GetWindowText (hwndEdit, pstrDoc, iLength + 1) ;
         
              // Search the document for the find string
         
         pstrPos = _tcsstr (pstrDoc + * piSearchOffset, pfr->lpstrFindWhat) ;
         free (pstrDoc) ;
         
              // Return an error code if the string cannot be found
         
         if (pstrPos == NULL)
              return FALSE ;
         
              // Find the position in the document and the new start offset
         
         iPos = pstrPos - pstrDoc ;
         * piSearchOffset = iPos + lstrlen (pfr->lpstrFindWhat) ;
         
              // Select the found text
         
         SendMessage (hwndEdit, EM_SETSEL, iPos, * piSearchOffset) ;
         SendMessage (hwndEdit, EM_SCROLLCARET, 0, 0) ;
         
         return TRUE ;
    }
    分析一下可能有用