_setmaxstdio_setmaxstdio

设置在流 I/O 级别同时打开的最大文件数。Sets a maximum for the number of simultaneously open files at the stream I/O level.

语法Syntax

int _setmaxstdio(
   int new_max
);

参数Parameters

new_maxnew_max
在流 I/O 级别同时打开的新的最大文件数。New maximum for the number of simultaneously open files at the stream I/O level.

返回值Return Value

如果成功,返回 new_max;否则,返回 -1。Returns new_max if successful; -1 otherwise.

如果 new_max 小于 _IOB_ENTRIES 或大于操作系统中可用的句柄的最大数量,则调用无效参数处理程序,如参数验证中所述。If new_max is less than _IOB_ENTRIES, or greater than the maximum number of handles available in the operating system, the invalid parameter handler is invoked, as described in Parameter Validation. 如果允许执行继续,则此函数将返回 -1 并将 errno 设置为 EINVAL。If execution is allowed to continue, this function returns -1 and sets errno to EINVAL.

有关这些及其他错误代码的信息,请参阅 _doserrno、errno、_sys_errlist 和 _sys_nerrFor information about these and other error codes, see _doserrno, errno, _sys_errlist, and _sys_nerr.

备注Remarks

_setmaxstdio 函数更改可在流 I/O 级别同时打开的文件数的最大值。The _setmaxstdio function changes the maximum value for the number of files that may be open simultaneously at the stream I/O level.

C 运行时 I/O 现在支持在低 I/O 级别同时打开最多 8,192 个文件。C run-time I/O now supports up to 8,192 files open simultaneously at the low I/O level. 此级别包括使用 I/O 函数的 _open、_read 和 _write 系列打开和访问的文件。This level includes files opened and accessed using the _open, _read, and _write family of I/O functions. 默认情况下,在流 I/O 级别可以同时打开最多 512 个文件。By default, up to 512 files can be open simultaneously at the stream I/O level. 此级别包括使用函数的 fopen、fgetc 和 fputc 系列打开和访问的文件。This level includes files opened and accessed using the fopen, fgetc, and fputc family of functions. 使用 _setmaxstdio 函数可以将在流 I/O 级别最多打开 512 个文件的限制增加到最多 8,192 个文件。The limit of 512 open files at the stream I/O level can be increased to a maximum of 8,192 by use of the _setmaxstdio function.

因为 fopen 等流 I/O 级别函数是基于低 I/O 级别函数生成的,8,192 的最大值是通过 C 运行时库访问的同时打开文件数的硬上限。Because stream I/O-level functions, such as fopen, are built on top of the low I/O-level functions, the maximum of 8,192 is a hard upper limit for the number of simultaneously open files accessed through the C run-time library.

备注

此上限可能会超过特定 Win32 平台和配置所支持的文件数。This upper limit might be beyond what's supported by a particular Win32 platform and configuration.

要求Requirements

例程所返回的值Routine 必需的标头Required header
_setmaxstdio_setmaxstdio <stdio.h><stdio.h>

有关更多兼容性信息,请参阅 兼容性For more compatibility information, see Compatibility.

示例Example

请参阅 _getmaxstdio,获取使用 _setmaxstdio 的示例。See _getmaxstdio for an example of using _setmaxstdio.

请参阅See also

流 I/OStream I/O