Windows API 之 FineFirstFile、FindNextFile
参考:https://msdn.microsoft.com/en-us/library/aa364418%28VS.85%29.aspx
FindFirstFile
Searches a directory for a file or subdirectory with a name that matches a specific name (or partial name if wildcards are used).
BOOL WINAPI FindNextFile(
_In_ HANDLE hFindFile,
_Out_ LPWIN32_FIND_DATA lpFindFileData
);
Parameters
- lpFileName [in]
-
The directory or path, and the file name, which can include wildcard characters, for example, an asterisk (*) or a question mark (?).
This parameter should not be NULL, an invalid string (for example, an empty string or a string that is missing the terminating null character), or end in a trailing backslash (\).
If the string ends with a wildcard, period (.), or directory name, the user must have access permissions to the root and all subdirectories on the path.
In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. For more information, see Naming a File.
- lpFindFileData [out]
-
A pointer to the WIN32_FIND_DATA structure that receives information about a found file or directory.
参考:https://msdn.microsoft.com/en-us/library/windows/desktop/aa364428%28v=vs.85%29.aspx
FindNextFile function
Continues a file search from a previous call to the FindFirstFile, FindFirstFileEx, or FindFirstFileTransacted functions.
BOOL WINAPI FindNextFile(
_In_ HANDLE hFindFile,
_Out_ LPWIN32_FIND_DATA lpFindFileData
);
Parameters
- hFindFile [in]
-
The search handle returned by a previous call to the FindFirstFile or FindFirstFileEx function.
- lpFindFileData [out]
-
A pointer to the WIN32_FIND_DATA structure that receives information about the found file or subdirectory.
Return value
If the function succeeds, the return value is nonzero and the lpFindFileData parameter contains information about the next file or directory found.
If the function fails, the return value is zero and the contents of lpFindFileData are indeterminate. To get extended error information, call the GetLastError function.
If the function fails because no more matching files can be found, the GetLastError function returns ERROR_NO_MORE_FILES.
参考:
http://www.oschina.net/code/piece_full?code=6095&piece=9712#9712
遍历目录:
int SearchStrHead(string szCur2)
{
int i = ;
WIN32_FIND_DATA FindData = { };
HANDLE hTravseDir = FindFirstFile(szCur2.c_str(), &FindData);
//cout <<"First:" << FindData.cFileName << endl; if (hTravseDir == INVALID_HANDLE_VALUE)
{ cout << GetLastError() << endl;
return ;
} while (FindNextFile(hTravseDir, &FindData))
{
if (strcmp(FindData.cFileName, ".") ==
|| strcmp(FindData.cFileName, "..") == )
{
continue;
}
//cout << i++ << " ";
//cout << FindData.cFileName << endl;
if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
string szCur3 = szCur2;
szCur3.erase(szCur3.find_last_of("*"));
//string sTemp = '\\' + (string)FindData.cFileName;
szCur3 += "\ ";
szCur3 += FindData.cFileName;
szCur3 += "\\*";
szCur3.erase(szCur3.find_last_of(" "), );
cout << szCur3 << endl; SearchStrHead(szCur3);
}
}
FindClose(hTravseDir);
return ;
}
Windows API 之 FineFirstFile、FindNextFile的更多相关文章
- Windows API 函数列表 附帮助手册
所有Windows API函数列表,为了方便查询,也为了大家查找,所以整理一下贡献出来了. 帮助手册:700多个Windows API的函数手册 免费下载 API之网络函数 API之消息函数 API之 ...
- 初识【Windows API】--文本去重
最近学习操作系统中,老师布置了一个作业,运用系统调用函数删除文件夹下两个重复文本类文件,Linux玩不动,于是就只能在Windows下进行了. 看了一下介绍Windows API的博客: 点击打开 基 ...
- 一些Windows API导致的Crash以及使用问题总结
RegQueryValueEx gethostbyname/getaddrinfo _localtime64 FindFirstFile/FindNextFile VerQueryValue Crea ...
- Windows API Finishing
input { font-size: 14px; height: 26px } td { border-style: none; border-color: inherit; border-width ...
- Windows API教程文件系统
本篇文章主要介绍了"Windows API教程文件系统",主要涉及到Windows API教程文件系统方面的内容,对于Windows API教程文件系统感兴趣的同学可以参考一下. ...
- Windows API函数大全(完整)
Windows API函数大全,从事软件开发的朋友可以参考下 1. API之网络函数 WNetAddConnection 创建同一个网络资源的永久性连接 WNetAddConnection2 创建同一 ...
- 一些Windows API导致的Crash以及使用问题总结(API的AV失败,可以用try catch捕捉后处理)
RegQueryValueEx gethostbyname/getaddrinfo _localtime64 FindFirstFile/FindNextFile VerQueryValue Crea ...
- [windows菜鸟]Windows API函数大全(完整)
Windows API函数大全,从事软件开发的朋友可以参考下 1. API之网络函数 WNetAddConnection 创建同一个网络资源的永久性连接 WNetAddConnection2 创建同一 ...
- WINDOWS API 大全(一)
1. API之网络函数 WNetAddConnection 创建同一个网络资源的永久性连接 WNetAddConnection2 创建同一个网络资源的连接 WNetAddConnection3 创建同 ...
随机推荐
- UIScrollView 加载多个view view还可以交换顺序(1)
#import "ViewController.h" #define kWidthOfScreen self.view.frame.size.width #define kHeig ...
- 使用日志记录功能查看PHP扩展的执行过程
了解过PHP内核的同学都知道,PHP的一次请求的生命周期 1.启动Apache后,PHP解释程序也随之启动.PHP调用各个扩展的MINIT方法,从而使这些扩展切换到可用状态 2.当一个页面请求发生时, ...
- url 取出文件扩展名
/**url 取出文件扩展名 *///方法一function getExt1($url) { $arr = parse_url($url); $file = basename($arr[' ...
- mysql表备份及还原
备份 导出数据库所有表结构 ? 1 mysqldump -uroot -ppassword -d dbname > db.sql 导出数据库某个表结构 ? 1 mysqldump -uroot ...
- log4j2配置MDC分线程写日志
1.MDC是一个高级一些的工具,可以配置分用户(userid)写日志,也可以分线程 2.方法和道理都是相似的,在写入日志之前配置线程名或者用户id 3.如果将线程名配置为目录,可以将不同线程的日志输送 ...
- Tomcat开发技术之与HTTP服务器的集成
Tomcat最主要的功能是提供Servlet/jsp容器,尽管它也可以作为独立的Java Web服务器,它在对静态资源(如Html文件或图像文件)的处理速度,以及提供的Web服务器治理功能方面都不如其 ...
- iOS打上线包或者测试包详细流程
首先登陆苹果官方开发者账号:http://developer.apple.com 进入到如下界面 之后进入如下界面:点击第二项创建证书 整个流程如下图4步 然后按照如下图片进行配置即可 接下来去创建C ...
- 《C++ Primer》之重载操作符与转换(下)
转换与类类型 可用一个实参调用的非 explicit 构造函数定义一个隐式转换.当提供了实参类型的对象而需要一个类类型的对象时,编译器将使用该转换.这种构造函数定义了到类类型的转换.除了定义到类类型的 ...
- Robotium第一天:搭建环境测试微信
因为要在命令行下运行一些android的工具,所以配置一些环境变量会比较方便: 遇到问题: java -jar re-sign.jar 出现提示android路径没有配置好: 需要配置如下: 配置AN ...
- mb_detect_encoding() 运行sitemap.php 字符编码不能转换修改php.ini
1.phpinfo() 找php.ini位置 2.备份然后 php.ini文件中顶部添加extension=php_mbstring.dll Call to undefined function mb ...