【MSDN】由文件路径获得文件名--PathFindFileName()函数

来源:互联网 发布:理财软件排名 编辑:程序博客网 时间:2024/05/17 09:02
今天偶然翻看MFC源代码,发现了一个函数PathFindFileName(),这个函数的作用就是用来获取路径中的文件名的。下面是MSDN的文档。
LPTSTR PathFindFileName(      LPCTSTR pPath      );  

Searches a path for a file name.

  • Returns a pointer to the address of the string if successful, or a pointer to the beginning of the path otherwise.
pPath
Address of the file name for which to search.


在MSDN中还发现了以下函数:

由文件路径判断文件是否存在的函数
BOOL PathFileExists(      LPCTSTR lpszPath      );  

Determines if a file exists.

  • Returns TRUE if the file exists, or FALSE otherwise.
lpszPath
Address of the file to verify.

This function will test for the validity of the file and path.

由文件路径获得文件扩展名的函数

LPTSTR PathFindExtension(      LPCTSTR pPath      );  

Searches a path for an extension.

  • Returns the address of the "." preceding the extension within pPath if an extension is found, or the address of the trailing NULL character otherwise.
pPath
Address of the path that contains the extension for which to search.

由文件路径返回下一层路径的函数

LPTSTR PathFindNextComponent(      LPCTSTR pszPath      );  

Parses a path for the next path component. Paths are delimited by backslashes or by the NULL at the end of the path.

  • Returns the address of the start of the next path component if successful, or NULL otherwise.
pszPath
Address of the path to search.

在给定的目录下搜索指定文件的函数

BOOL PathFindOnPath(      LPTSTR    pszFile,      LPCTSTR * ppszOtherDirs      );  

Finds a file within a given path.

  • Returns TRUE if successful, or FALSE otherwise.
pszFile
Address of the file name for which to search.
ppszOtherDirs

Address of the path to be searched.



转自:http://blog.163.com/lvan100@yeah/blog/static/681172142010118114235316/

原创粉丝点击