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

标签: ,

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

PTSTR PathFindFileName(
    __in  PTSTR pPath
);

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

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

/*
 * Author: Demon
 * Date: 2012/6/6
 * Website: https://demon.tw
 */
#include <stdio.h>
#include <Shlwapi.h>

int main()
{
    char path[] = "C:\\Windows\\System32/notepad.exe";
    /* will output "notepad.exe" */
    printf("%s\n", PathFindFileName(path));
    return 0;
}
赞赏

微信赞赏支付宝赞赏

随机文章:

  1. Raspberry Pi树莓派新系统SSH连接被拒绝的解决方法
  2. VBS实现半角字符转全角字符
  3. VBS的SendKeys,你真的懂吗?
  4. VBS实现全角字符转半角字符
  5. 利用 WindowsInstaller.Installer 对象计算文件 MD5 hash 值

留下回复