Search the FAQ Archives

3 - A - B - C - D - E - F - G - H - I - J - K - L - M
N - O - P - Q - R - S - T - U - V - W - X - Y - Z
faqs.org - Internet FAQ Archives

comp.os.msdos.programmer FAQ part 3/5
Section - - How can my program open more files than DOS's limit of 20?

( Part1 - Part2 - Part3 - Part4 - Part5 - Single Page )
[ Usenet FAQs | Web FAQs | Documents | RFC Index | Zip codes ]


Top Document: comp.os.msdos.programmer FAQ part 3/5
Previous Document: - How can I redirect stderr?
Next Document: - How can I read, create, change, or delete the volume label?
See reader questions & answers on this topic! - Help others by sharing your knowledge
Date: 5 Feb 2002 22:03:03 -0400

 This is a summary of an article Ralf Brown posted on 8 August 1992, with
 some additions from a Microsoft tech note and information from Chin
 Huang.)

 DOS imposes some limits. Once you overcome those, which is pretty easy,
 you may have to take additional measures to overcome the limitations
 built into your compiler's run- time library.

 1) Limitations imposed by DOS:

 There are separate limits on files and file handles. For example, DOS
 opens three files but five file handles: CON (stdin, stdout, and
 stderr), AUX (stdaux), and PRN (stdprn).

 The limit in FILES= in CONFIG.SYS is a system-wide limit on files opened
 by all programs (including the three that DOS opens and any opened by
 TSRs); each process has a limit of 20 handles (including the five that
 DOS opens). Example: CONFIG.SYS has FILES=40. Then program #1 will be
 able to open 15 file handles. Assuming that the program actually does
 open 15 handles pointing to 15 different files, other programs could
 still open a total of 22 files (40-3-15 = 22), though no one program
 could open more than 15 file handles. If you're running DOS 3.3 or
 later, you can increase the per-process limit of 20 file handles by a
 call to INT 21 AH=67, Set Handle Count. Your program is still limited by
 the system-wide limit on open files, so you may also need to increase
 the FILES= value in your CONFIG.SYS file (and reboot). The run-time
 library that you're using may have a fixed-size table of file handles,
 so you may also need to get source code for the module that contains the
 table, increase the table size, and recompile it.

 2) Limitations in Microsoft C run-time library:

 In Microsoft C the run-time library limits you to 20 file handles. To
 change this, you must be aware of two limits:

 File handles used with _open(), _read(), etc.: Edit _NFILE_ in
 CRT0DAT.ASM.

 Stream files used with fopen(), fread(), etc.: Edit _NFILE_ in _FILE.C
 for DOS or FILE.ASM for Windows/QuickWin. This must not exceed the value
 of _NFILE_ in CRT0DAT.ASM. (QuickWin uses the constant _WFILE_ in
 CRT0DAT.ASM and WFILE.ASM for the maximum number of child text windows.)

 After changing the limits, recompile using CSTARTUP.BAT. Microsoft
 recommends that you first read README.TXT in the same directory.

 3) Limitations in Borland C++ run-time library:

 (Reader Chin Huang provided this information on 12 Sep 1993.) To
 increase the open file limit for a program you compile with Borland C++
 3.1, edit the file _NFILE.H in the include directory and change the
 _NFILE_ value. Compile and link the modules FILES.C and FILES2.C from
 the lib directory into your program.

User Contributions:

Comment about this article, ask questions, or add new information about this topic:




Top Document: comp.os.msdos.programmer FAQ part 3/5
Previous Document: - How can I redirect stderr?
Next Document: - How can I read, create, change, or delete the volume label?

Part1 - Part2 - Part3 - Part4 - Part5 - Single Page

[ Usenet FAQs | Web FAQs | Documents | RFC Index ]

Send corrections/additions to the FAQ Maintainer:
jeffrey@carlyle.org (Jeffrey Carlyle)





Last Update March 27 2014 @ 02:11 PM