首页 > 其他 > 详细

PathFindFileName函数,由文件路径获得文件名

时间:2014-07-24 10:10:23      阅读:392      评论:0      收藏:0      [点我收藏+]

PathFindFileName函数的作用是返回路径中的文件名。

PTSTR PathFindFileName(
    __in  PTSTR pPath
);

pPath是指向文件路径字符串的指针,函数返回指向文件名的指针(如果找到的话),否则返回指向路径开头的指针。

PathFindFileName既支持Windows下的反斜杆,也支持Unix下的斜杠,还支持斜杆和反斜杠的混合,

例如:

 1      
 2      * Author: Chechen
 3      * Date: 2014/7/24
 4      */
 5     #include <stdio.h>
 6     #include <Shlwapi.h>
 7 
 8     int main()
 9     {
10         char path[] = "C:\\Windows\\System32/notepad.exe";
11         /* will output "notepad.exe" */
12         printf("%s\n", PathFindFileName(path));
13         return 0;
14     }

获取指定的系统路径 SHGetSpecialFolderPath

1 1  #include   <shlobj.h>   
2 2  #pragma   comment(lib,   "shell32.lib")   
3 3    
4 4  TCHAR   szPath[MAX_PATH];
5       SHGetSpecialFolderPathNULL,szPath,CSIDL_COMMON_DOCUMENTS,   FALSE);   
6 5  //   szPath   就是

 

PathFindFileName函数,由文件路径获得文件名,布布扣,bubuko.com

PathFindFileName函数,由文件路径获得文件名

原文:http://www.cnblogs.com/chechen/p/3864812.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!