Increased File Libraries for Visual C++ 1.0 Available (124519)



The information in this article applies to:

  • The C Run-Time (CRT), when used with:
    • Microsoft Visual C++, 32-bit Editions 1.0

This article was previously published under Q124519

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.

You can, however, increase these limits by downloading the Increased File Handle Libraries for Microsoft Visual C++, 32-bit Edition, Version 1.0.

The following files are available for download from the Microsoft Download Center:


Vcntxf.exe

For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.

MORE INFORMATION

Preset Limits

Attempting 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 MSVCRT10.DLL.

Increased Limits Using the Files in VCNTXF.EXE

The Increased File Handle Libraries for Microsoft Visual C++ 32-bit Edition, Version 1.0 available in VCNTXF.EXE include the following five files:
   README.TXT   - File containing instructions on use of these .LIBs
   LIBC.LIB     - Single threaded run-time library
   LIBCMT.LIB   - Multi-threaded run-time library
   MSVCRT1X.LIB - Import library for MSVCRT1X.DLL
   MSVCRT1X.DLL - Multi-threaded run-time library in a DLL.
				
These run-time libraries have been rebuilt to allow the use of up to 253 file handles and up to 125 file streams in an application. The total is actually 256 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 \MSVCNT\LIB directory, make a backup copy of the existing libraries of the same name.

For MSVCRT1X.LIB to be used as a default library, you must rename it to MSVCRT.LIB. If you use this library, MSVCRT1X.DLL must be in your path or in your Windows system directory. You may distribute MSVCRT1X.DLL with applications built with MSVCRT1X.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.

Modification Type:MinorLast Reviewed:8/5/2004
Keywords:kbdownload kbfile kbProgramming KB124519 kbAudDeveloper