参考: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的更多相关文章

  1. Windows API 函数列表 附帮助手册

    所有Windows API函数列表,为了方便查询,也为了大家查找,所以整理一下贡献出来了. 帮助手册:700多个Windows API的函数手册 免费下载 API之网络函数 API之消息函数 API之 ...

  2. 初识【Windows API】--文本去重

    最近学习操作系统中,老师布置了一个作业,运用系统调用函数删除文件夹下两个重复文本类文件,Linux玩不动,于是就只能在Windows下进行了. 看了一下介绍Windows API的博客: 点击打开 基 ...

  3. 一些Windows API导致的Crash以及使用问题总结

    RegQueryValueEx gethostbyname/getaddrinfo _localtime64 FindFirstFile/FindNextFile VerQueryValue Crea ...

  4. Windows API Finishing

    input { font-size: 14px; height: 26px } td { border-style: none; border-color: inherit; border-width ...

  5. Windows API教程文件系统

    本篇文章主要介绍了"Windows API教程文件系统",主要涉及到Windows API教程文件系统方面的内容,对于Windows API教程文件系统感兴趣的同学可以参考一下. ...

  6. Windows API函数大全(完整)

    Windows API函数大全,从事软件开发的朋友可以参考下 1. API之网络函数 WNetAddConnection 创建同一个网络资源的永久性连接 WNetAddConnection2 创建同一 ...

  7. 一些Windows API导致的Crash以及使用问题总结(API的AV失败,可以用try catch捕捉后处理)

    RegQueryValueEx gethostbyname/getaddrinfo _localtime64 FindFirstFile/FindNextFile VerQueryValue Crea ...

  8. [windows菜鸟]Windows API函数大全(完整)

    Windows API函数大全,从事软件开发的朋友可以参考下 1. API之网络函数 WNetAddConnection 创建同一个网络资源的永久性连接 WNetAddConnection2 创建同一 ...

  9. WINDOWS API 大全(一)

    1. API之网络函数 WNetAddConnection 创建同一个网络资源的永久性连接 WNetAddConnection2 创建同一个网络资源的连接 WNetAddConnection3 创建同 ...

随机推荐

  1. ***C - I love sneakers!(动态规划,分组背包)

    C - I love sneakers! Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64 ...

  2. 关于maven相互依赖的工程部署问题

    环境:win7 64位,myeclipse10.6,eclipse4.5,都配置了svn插件 问题描述:1.工程模块化之后都是通过pom配置model来关联的,svn提交之后,通过myeclipse的 ...

  3. 移动端解决input focus后键盘弹出,高度被挤压的问题

    //解决弹出键盘页面高度变化bug var viewHeight = window.innerHeight; //获取可视区域高度 $("input").focus(functio ...

  4. 手把手教你ranorex_android自动化测试第一个示例

    要说android的自动化,那真是折腾死我了,从早期的monkeyrunner,到后来的robotium,再到最新的uiautomator,各有各的问题,总之性价比都不够高,不太适合我的使用场景.于是 ...

  5. SELECT TOP 1 * FROM是什么意思

    SELECT TOP 1 * FROM的含义: 1.select为命令动词,含义为执行数据查询操作: 2.top 1子句含义为查询结果只显示首条记录: 3.*子句表示查询结果包括数据源中的所有字段: ...

  6. JavaScript高级程序设计:第十四章

    第十四章 一.表单的基础知识 在HTML中,表单是由<form>元素来表示的,而在javascript中,表单对应的则是HTMLFormElement类型.HTMLFormElement继 ...

  7. 更改web project 访问项目名称

    1.新建web project 2.右键该项目名称------properties 3.访问该项目的URL http://localhost:8806/ssm/.......... 相比书写整个项目名 ...

  8. Cake

    Cake Time Limit : 1000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Total Submissi ...

  9. svn rollback: 恢复到上一版本

    18:48:32svn的文件版本是168,我想用167的版本覆盖掉168的版本如何搞? 18:52:47先把本地的那个文件用rm命令删掉,然后,使用svn up -r 167 文件路径,UP下来的文件 ...

  10. SQL SERVER与C#的数据类型对应表

    序号 类别 SQLServer C Sharp 备注 1 整数 bit Boolean True转换为1False转换为0 2 tinyint Byte C Sharp 数据类型都位于System命名 ...