《转》GetFileTitle与文件扩展名是否显示有关

<转自> http://blog.csdn.net/zhang1chao5/article/details/7492708

使用MSDN上GetFileName里的示例代码,发现我的结果和MSDN上的不一样

 try
   {
      // try to open the file
      CFile sysFile(_T("C:\\WINDOWS\\SYSTEM.INI"), CFile::modeRead);


      // print out path name and title information
      _tprintf(_T("Path is : \"%s\"\n"), (LPCTSTR) sysFile.GetFilePath());
      _tprintf(_T("Name is : \"%s\"\n"), (LPCTSTR) sysFile.GetFileName());
      _tprintf(_T("Title is: \"%s\"\n"), (LPCTSTR) sysFile.GetFileTitle());


      // close the file handle
      sysFile.Close();
   }
   catch (CFileException* pEx)
   {
      // if an error occurs, just make a message box
      pEx->ReportError();
      pEx->Delete();
   }

output

Path is : "C:\WINDOWS\SYSTEM.INI"

Name is : "SYSTEM.INI"

Title is: "SYSTEM.INI

 

经过搜索发现居然还跟目标机器是否 在文件夹布局和搜索-》查看-》隐藏已知文件类型拓展名选项 是否被勾选有关!!!尼玛,微软,这函数设计接口,这是闹哪样啊??

显示文件扩展名 GetFileTitle 就会得到带有扩展名的 字符串;否则没有扩展名。

原文地址:https://www.cnblogs.com/zzugyl/p/2984994.html