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 创建同 ...
随机推荐
- alertview 添加图片
- (void)willPresentAlertView:(UIAlertView *)alertView { 在这个方法中, 绘制需要的东西 uiview *myView = [uiview all ...
- C# 在word文档中复制表格并粘帖到下一页中
C# 在word文档中复制表格并粘帖到下一页中 object oMissing = System.Reflection.Missing.Value; Microsoft.Offi ...
- 使用node.js创建第一个应用
node.js应用组成部分 1.引入require模块:我们可以使用require指令来载入Node.js模块. 2.创建服务器:服务器可以监听客户端的请求,类似于Apache,Nninx等HTTP服 ...
- Ubuntu cron定时执行任务
1.添加自定义事件 crontab -e 2.选定编辑器 3.添加执行代码 * * * * /usr/bin/curl http://www.exmple.com/cron.php crontab 命 ...
- 批量创建IP方法
以下教程,将告诉大家如何在Windows系统中通过命令行,批量添加IP.目标,在本机的的网卡名称为“本地连接”的网卡中,批量添加192.168.1段的ip地址,起开始IP为10,每次增加1,知道22为 ...
- 第五节 面向连接传输:TCP
第五节 面向连接传输:TCP TCP概述RFCs:793,1122,1323,2018,2581 点对点: 一个发送方,一个接收方 可靠,按序的字节流: 无“报文边界”,无结构但有 ...
- H5的新应用-指定视频的播放进度
<!DOCTYPE html> <html> <head> <title>指定视频的播放进度</title> <meta http-e ...
- Codeforces 237C
题目: Description You've decided to carry out a survey in the theory of prime numbers. Let us remind y ...
- python2.6.6在centos6.4下安装
1.wget http://www.python.org/ftp/python/2.6.6/Python-2.6.6.tar.bz2 2. tar xvjf Python-2.6.6.tar.bz2 ...
- 修改一个Label上字体的大小(富文本)
假如修改上面的Label上价格30000的大小,那么需要用到富文本 上代码 // 字符串30000 NSString * priceNumber = @"30000"; [pric ...