The information in this article applies to:
SUMMARY
The run-time libraries have a preset limit on the number of files you
can have open at one time as described in the More Information section
of this article.
http://www.microsoft.com/downloads/search.aspand then click How to use the Microsoft Download Center. For more information about downloading files from the Microsoft Software Library, please see the following article in the Microsoft Knowledge Base: Q119591 How to Obtain Microsoft Support Files from Online Services MORE INFORMATIONPreset LimitsAttempting to open more than 64 file handles (or 20 file streams) concurrently in a process will fail if you are creating a single- threaded application that uses the static run-time library (LIBC.LIB) by using the /ML compiler option (the default). Attempting to open more than 256 files handles (or 40 file streams) concurrently in a process will fail if you are using the static multi-threaded run-time library by using the /MT compiler option and LIBCMT.LIB. The same limit applies if you use the DLL version of the run-time library by using the /MD compiler option and MSVCRT.LIB or MSVCRT20.DLL. Increased Limits Using the Files in VC20XF.EXE & VC22XF.EXEVC20XF.EXE ans VC22XF.EXE include the following five files:
These run-time libraries have been rebuilt to allow the use of up to 509 file handles and up to 125 file streams in an application. The total is actually 512 handles and 128 streams, but three handles and streams are used by the run-time library for the standard C input/output/error files, stdin, stdout, and stderr. Note that each stream (FILE*) uses a handle, so the two limits are not independent of each other. When building your application, the libraries must be in your current directory, or in a directory specified by the LIB environment variable. If you place them in the \MSVC20\LIB directory, make a backup copy of the existing libraries of the same name. For MSVCRT2X.LIB to be used as a default library, you must rename it to MSVCRT.LIB. If you use this library, MSVCRT2X.DLL must be in the path or in the Windows system directory. You may distribute MSVCRT2X.DLL with applications built with MSVCRT2X.LIB. These files are provided for the convenience of Visual C++ users; they are provided as is without any support. File handles are obtained when you use the low-level I/O functions (_open and _sopen, and _creat) to open a file. When one of these functions fails because the application has reached the file limit, they will return -1, and set the global variable errno to the constant EMFILE. EMFILE is defined in ERRNO.H as 24. File handles are also associated with the iostream classes. When a member function or constructor of an iostream class fails because the application has reached the file limit, the bad member function will return a nonzero value. Note that many other types of errors can also cause the bad member function to return a nonzero value. File streams are associated with the stream I/O functions (fopen, _fdopen, and _fsopen). When one of these functions fails because the application has reached the file limit, they will return NULL. Note that many other types of file stream errors can also cause the functions to return NULL. NOTE: You must call SetHandleCount() to increase the number of file handles available on WIN32s. This function changes the number of file handles available to a process. Under Win32s, this default is 20. It has no effect when called under Windows NT. Additional query words: runtime vc++
Keywords : kbfile kbprg kbCRT kbVC |
Last Reviewed: December 15, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |