查找与以前 _findfirst 调用中的 filespec 参数相匹配的下一个名称(如有),然后相应更改 fileinfo 结构内容。
语法
int _findnext(
intptr_t handle,
struct _finddata_t *fileinfo
);
int _findnext32(
intptr_t handle,
struct _finddata32_t *fileinfo
);
int _findnext64(
intptr_t handle,
struct __finddata64_t *fileinfo
);
int _findnexti64(
intptr_t handle,
struct __finddatai64_t *fileinfo
);
int _findnext32i64(
intptr_t handle,
struct _finddata32i64_t *fileinfo
);
int _findnext64i32(
intptr_t handle,
struct _finddata64i32_t *fileinfo
);
int _wfindnext(
intptr_t handle,
struct _wfinddata_t *fileinfo
);
int _wfindnext32(
intptr_t handle,
struct _wfinddata32_t *fileinfo
);
int _wfindnext64(
intptr_t handle,
struct _wfinddata64_t *fileinfo
);
int _wfindnexti64(
intptr_t handle,
struct _wfinddatai64_t *fileinfo
);
int _wfindnext32i64(
intptr_t handle,
struct _wfinddatai64_t *fileinfo
);
int _wfindnext64i32(
intptr_t handle,
struct _wfinddata64i32_t *fileinfo
);
参数
handle
搜索以前调用 _findfirst 返回的句柄。
fileinfo
文件信息缓冲区。
返回值
如果成功,则返回 0。 否则返回 -1,并将 errno 设置为指示失败性质的值。 下表中显示了可能的错误代码。
errno 值 |
条件 |
|---|---|
EINVAL |
无效参数:fileinfo 为 NULL。 或者,操作系统返回了意外错误。 |
ENOENT |
找不到更多匹配的文件。 |
ENOMEM |
内存不足或文件名称长度超出 MAX_PATH。 |
如果传入了无效参数,这些函数会调用无效参数处理程序,如参数验证中所述。
注解
使用 _findfirst 或 _findnext 函数(或任何变体)后,必须调用 _findclose。 _findclose 会释放应用程序中这些函数使用的资源。
这些具有 w 前缀函数的变体都是宽字符版本;否则,它们与相应的单字节函数完全相同。
这些函数的变体支持 32 位或 64 位时间类型以及 32 位或 64 位文件大小。 第一个数字后缀(32 或 64)表示所用时间类型的大小;第二个后缀是 i32 或 i64,表示以 32 位还是 64 位整数表示文件大小。 有关支持 32 位和 64 位时间类型及文件大小的版本的信息,请参阅下表。 使用 64 位时间类型的变体允许文件创建日期最大表示为 3000 年 12 月 31 日 23:59:59,UTC;那些使用 32 位时间类型的变体只能表示截至 2038 年 1 月 18 日 23:59:59,UTC 之前的日期。 1970 年 1 月 1 日午夜是所有这些函数的日期范围下限。
除非有特定原因要使用显式指定时间大小的版本,否则请使用 _findnext 或 _wfindnext;如果需要支持大于 3 GB 的文件大小,请使用 _findnexti64 或 _wfindnexti64。 所有这些函数均使用 64 位时间类型。 在早期版本中,这些函数使用 32 位时间类型。 如果此更改是某应用程序的中断性变更,可定义 _USE_32BIT_TIME_T 来获取旧行为。 如果已定义 _USE_32BIT_TIME_T,则 _findnext、_findnexti64,及其对应的 Unicode 版本将使用 32 位时间。
默认情况下,此函数的全局状态范围限定为应用程序。 若要更改此行为,请参阅 CRT 中的全局状态。
_findnext 的时间类型和文件长度类型变体
| 函数 | 已定义 _USE_32BIT_TIME_T? |
时间类型 | 文件长度类型 |
|---|---|---|---|
| %> | 未定义 | 64 位 | 32 位 |
| %> | 已定义 | 32 位 | 32 位 |
| %> | 不受宏定义影响 | 32 位 | 32 位 |
| %> | 不受宏定义影响 | 64 位 | 64 位 |
| %> | 未定义 | 64 位 | 64 位 |
| %> | 已定义 | 32 位 | 64 位 |
| %> | 不受宏定义影响 | 32 位 | 64 位 |
| %> | 不受宏定义影响 | 64 位 | 32 位 |
一般文本例程映射
| Tchar.h 例程 | _UNICODE 和 _MBCS 未定义 |
_MBCS 已定义 |
_UNICODE 已定义 |
|---|---|---|---|
_tfindnext |
_findnext |
_findnext |
_wfindnext |
_tfindnext32 |
_findnext32 |
_findnext32 |
_wfindnext32 |
_tfindnext64 |
_findnext64 |
_findnext64 |
_wfindnext64 |
_tfindnexti64 |
_findnexti64 |
_findnexti64 |
_wfindnexti64 |
_tfindnext32i64 |
_findnext32i64 |
_findnext32i64 |
_wfindnext32i64 |
_tfindnext64i32 |
_findnext64i32 |
_findnext64i32 |
_wfindnext64i32 |
要求
| 函数 | 必需的标头 |
|---|---|
_findnext |
<io.h> |
_findnext32 |
<io.h> |
_findnext64 |
<io.h> |
_findnexti64 |
<io.h> |
_findnext32i64 |
<io.h> |
_findnext64i32 |
<io.h> |
_wfindnext |
<io.h> 或 <wchar.h> |
_wfindnext32 |
<io.h> 或 <wchar.h> |
_wfindnext64 |
<io.h> 或 <wchar.h> |
_wfindnexti64 |
<io.h> 或 <wchar.h> |
_wfindnext32i64 |
<io.h> 或 <wchar.h> |
_wfindnext64i32 |
<io.h> 或 <wchar.h> |
有关兼容性的详细信息,请参阅 兼容性。
库
C 运行时库的所有版本。