参考: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. python--zeros函数和ones函数

    使用numpy.zeros,numpy.ones,numpy.eye等方法可以构造特定的矩阵 例如: 代码如下: >>>from numpy import * >>> ...

  2. Gitlab 安装配置

    Gitlab 很好的替代Github,可以安装到公司的内网服务器 进行管理 ,可以分布式的管理,集中的管理 下面介绍安装这个软件的步骤 其实安装很简单的  按照官网可以安装 https://about ...

  3. Xcode调试之查看变量

    从其他开发语言转行进军IOS开发的小伙伴可能会有这样一件苦恼的事情,调试程序时如何查看变量值?我并不喜欢每次都要通过打印去查看变量的值,也不喜欢通过光标悬浮到变量上来显示变量的值,如果要查看变量的属性 ...

  4. jquery1.8.3和1.11.3的用法区别

    学习js啦dom的对象 发现好复杂 不够简洁 所以我就用法强大的jquery来做功课 突然就遇到attr的方法对复选属性的checked取不了值 给我返回undefined 我查好久都没查出问题 结果 ...

  5. CSS传统布局之布局模型

    刚开始准备这篇文章的时候,查到的有很多包含“布局模型”的中文博客或是资料,但是google上并未找到类似字眼,google到的是“flex layout module”“grid layout mod ...

  6. wireshark 包过滤

    tcp.port == 443 or udp.port==443 or tcp.port==53 or udp.port==53

  7. php curl 获取 HTTPS

    注意:谷歌的话开vpn可能才可以,goagent也不行function getHTTPS($url) {  $ch = curl_init();  curl_setopt($ch, CURLOPT_S ...

  8. Q promise API简单翻译

    详细API:https://github.com/kriskowal/q/wiki/API-Reference Q提供了promise的一种实现方式,现在在node中用的已经比较多了.因为没有中文的a ...

  9. Http Post与Get等

    Http定义了与服务器交互的不同方法,最基本的方法有4种,分别是GET,POST,PUT,DELETE.URL全称是资源描述符,我们可以这样认为:一个URL地址,它用于描述一个网络上的资源,而HTTP ...

  10. perl-cgi-form

    来源: http://www.cnblogs.com/itech/archive/2012/09/23/2698595.html http://www.cnblogs.com/itech/archiv ...