我在98下杖举进程时得到的是绝对路径。如:"d:\123\456\abc.exe"  ,现在我想不要绝对路径而只要可执行文件名,例如把字符串 "d:\123\456\abc.exe"  改为 abc.exe,请问如何处理?

解决方案 »

  1.   

    void _splitpath(
       const char *path,
       char *drive,
       char *dir,
       char *fname,
       char *ext 
    );
      

  2.   

    把这个字符串的后面你要的文件名提取出来就可以了啊。
    char *p="d:\123\456\abc.exe";
    p=p+n;  //n就是你要开始获取字符的位置
      

  3.   

    CFile file;
    file.Open("d:\\123\\456\\abc.exe" ,CFile::modeRead );
    CString strFileName= file.GetFileName( ) ;
      

  4.   

    CString temp="d:\\123\\446\\abc.exe";
    temp=temp.Right(temp.GetLength()-temp.ReverseFind('\\'));
      

  5.   

    CString path= "d:\123\456\abc.exe" 
    CString name;
    int max=path.GetLength();
    int i,pos;
    for(i=0;i<max;i++)
    {  if(path.GetAt(i)=='\\')   pos=i;
    }
    name=path.Mid(pos+1);