_setmaxstdio 最大打开文件只有 2048 个?

mar*_*tis 5 c windows

http://msdn.microsoft.com/en-us/library/6e3b887c(VS.80).aspx

有没有办法使用 _wopen 每个应用程序一次打开超过 2048 个文件。

32 或 64 位操作系统——同样的限制!

Mis*_*sty 5

不。通过查看 CRT 源代码,我们可以知道 CRT 限制了最大数量。

 /*
 * Make sure the request is reasonable.
 */
_VALIDATE_RETURN(((maxnum >= _IOB_ENTRIES) && (maxnum <= _NHANDLE_)), EINVAL, -1);
Run Code Online (Sandbox Code Playgroud)

NHANDLE

#define _NHANDLE_           (IOINFO_ARRAYS * IOINFO_ARRAY_ELTS)
Run Code Online (Sandbox Code Playgroud)

这些常数:

/*
 * Definition of IOINFO_L2E, the log base 2 of the number of elements in each
 * array of ioinfo structs.
 */
#define IOINFO_L2E          5

/*
 * Definition of IOINFO_ARRAY_ELTS, the number of elements in ioinfo array
 */
#define IOINFO_ARRAY_ELTS   (1 << IOINFO_L2E)

/*
 * Definition of IOINFO_ARRAYS, maximum number of supported ioinfo arrays.
 */
#define IOINFO_ARRAYS       64
Run Code Online (Sandbox Code Playgroud)

如您所见,它受到 CRT 实施的限制。


Jef*_*ter 1

请参阅Windows 中打开的文件数量是否有限制

从对已接受答案的评论来看,似乎没有办法改变这一点。也许您可以使用“CreateFile”api 调用来代替 _wopen?