【MoreWindows工作笔记7】PathIsPrefix 判断路径的包含关系
来源:互联网 发布:玩具战争防御塔数据 编辑:程序博客网 时间:2024/05/22 09:00
工作后比较忙,没大块的时间来酝酿博客的写作,所以随时记点笔记,一来方便自己查阅,二来也督促自己学习和总结。如果能对大家有所帮助,就更加开心了。
判断路径的包含关系是Windows系统复制移动文件夹的前置条件,比如将C:\test复制到C:\test\test1下就是不可行的。前一篇《【MoreWindows工作笔记6】PathCommonPrefix 路径的公共前缀》介绍了使用函数提取路径的公共前缀,并使用公共前缀来判断路径的包含关系,本篇将介绍一个更简单的API函数来判断路径的包含关系——PathIsPrefix。下面请看完整的代码示范和运行结果:
// 【MoreWindows工作笔记7】PathIsPrefix 判断路径的包含关系// http://blog.csdn.net/morewindows/article/details/17078627#include <windows.h>#include <Shlwapi.h>#include <string>#include <iostream>using namespace std;#pragma comment(lib, "shlwapi.lib")int main(){ printf(" 【MoreWindows工作笔记7】PathIsPrefix 判断路径的包含关系\n"); printf(" - http://blog.csdn.net/morewindows/article/details/17078627 -\n"); printf(" -- By MoreWindows( http://blog.csdn.net/MoreWindows ) --\n\n"); string src_path = "C:\\test1\\test"; //"\\home\\test1\\test"; string des_path = "C:\\test1\\test2"; //"\\home\\test1\\test2"; if (PathIsPrefix(src_path.c_str(), des_path.c_str())) cout<<"目标路径: "<<des_path<<" 包含\n"<<"源路径: "<<src_path<<endl; else cout<<"目标路径: "<<des_path<<" 不包含\n"<<"源路径: "<<src_path<<endl; cout<<"-----------------------------------"<<endl; return 0;}运行结果如图所示:
地址:http://blog.csdn.net/morewindows/article/details/17078627 转载请标明出处,谢谢。
欢迎关注微博:http://weibo.com/MoreWindows
- 【MoreWindows工作笔记7】PathIsPrefix 判断路径的包含关系
- PathIsPrefix 判断路径的包含关系
- 【MoreWindows工作笔记8】PathFindSuffixArrayW 路径是否有给定的后缀
- 【MoreWindows工作笔记6】PathCommonPrefix 路径公共前缀
- 【MoreWindows工作笔记5】StrFormatByteSize64 高端大气的显示文件大小
- 【MoreWindows工作笔记9】OleGetClipboard 访问剪切板的文本内容
- 【MoreWindows工作笔记11】EnumClipboardFormats 剪切板内容的数据格式
- 【MoreWindows工作笔记12】WM_DRAWCLIPBOARD 监视剪切板
- 【MoreWindows工作笔记12】WM_DRAWCLIPBOARD 监视剪切板
- 【MoreWindows工作笔记2】 查看当前系统使用的字符集 GetSystemDefaultLocaleName
- 【MoreWindows工作笔记10】OleGetClipboard 访问剪切板上的文件信息
- Python 判断列表的包含关系
- 判断两个集合包含关系
- C++判断两个序列的包含关系: std::includes
- Shell判断字符串包含关系的几种方法
- Shell判断字符串包含关系的几种方法
- Shell判断字符串包含关系的几种方法
- Shell判断字符串包含关系的几种方法
- javascript技巧整理(2)
- C++的数组不支持多态”?
- javascript技巧整理(3)
- 【MoreWindows工作笔记6】PathCommonPrefix 路径公共前缀
- 数组大折腾。(二)
- 【MoreWindows工作笔记7】PathIsPrefix 判断路径的包含关系
- oracle学习之bulk collect用法
- 【MoreWindows工作笔记8】PathFindSuffixArrayW 路径是否有给定的后缀
- 函数指针作为函数参数
- 常量折叠的理解
- C++ 虚函数表解析
- Linux网络编程--TCP的套接字通信学习笔记
- 冒个泡
- sgu 525 Revolutionary Roads