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

来源:互联网 发布:苹果阴阳师网络未连接 编辑:程序博客网 时间:2024/04/30 13:00

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

 

[cpp] view plaincopyprint?
  1. PTSTR PathFindFileName(  
  2.     __in  PTSTR pPath  
  3. );  


 

 

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

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

[cpp] view plaincopyprint?
  1. /* 
  2.  * Author: Demon 
  3.  * Date: 2012/6/6 
  4.  * Website: http://demon.tw 
  5.  */  
  6. #include <stdio.h>  
  7. #include <Shlwapi.h>  
  8.   
  9. int main()  
  10. {  
  11.     char path[] = "C:\\Windows\\System32/notepad.exe";  
  12.     /* will output "notepad.exe" */  
  13.     printf("%s\n", PathFindFileName(path));  
  14.     return 0;  
  15. }  
更多

转自:http://blog.csdn.net/setflvet/article/details/8280137
原创粉丝点击