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 创建同 ...
随机推荐
- iOS应用性能调优的4个建议和技巧
任何一个能在用户手机屏幕中占有一席之地的iOS app都包含3个关键因素:想法好.设计出色.性能卓越.本文将分享一些iOS应用性能调优的4个建议和技巧. Tip #1:把图片资源压缩到最小. i ...
- 杭电20题 Human Gene Functions
Problem Description It is well known that a human gene can be considered as a sequence, consisting o ...
- php中文乱码问题分析及解决办法
中文乱码问题产生的原因,主要就是字符编码设置问题: 首先,mysql数据库安装的时候字符编码要选择正确,最好选择utf-8比较保险.如果安装时没有设置正确,找到mysql的安装 ...
- C# 读取二进制文件
using UnityEngine; using System.Collections; using System; using System.IO; public class Test : Mono ...
- TODO:小程序的使用体验
TODO:小程序的使用体验 2017.01.09小程序如期而至,话说十年前的今天2007.01.09是第一代iPhone发布日期. 清晨朋友圈发了一张小程序的截图,很多朋友问用什么版本的微信才有小程序 ...
- java代码如何读取properties文件
我们在开发工程中,有时候需要在Java代码中定义一些在部署生产环境时容易改变的变量,还需要我们单独放在一个外部属性文件中,方便我们将来修改.这里列出了两种比较方便的方式. 一.在Spring配置文件中 ...
- 《JS权威指南学习总结--4.13运算符》
一.typeof运算符 typeof是一元运算符,放在其单个操作数的前面,操作数可以是任意类型.返回值为表示操作数类型的一个字符串. 例如: typeof x ...
- crossdomain 可用
<cross-domain-policy> <allow-access-from domain="*"/> <allow-http-request-h ...
- 【转】PHP android ios相互兼容的AES加密算法
APP项目用户密码传输一直没有用HTTPS,考虑到用户的隐私暂时先用AES对密码加密,以后也可以用于手机端与服务端加密交互. PHP的免费版phpAES项目,手机端解码各种不对. 好不容易找了PHP ...
- window.open页面关闭后刷新父页面
如题 function openWin(url,text,winInfo){ var winObj = window.open(url,text,winInfo); var loop = setInt ...