Technical Information Database TI221B.txt Setting File Handles For A Windows BDE Application Category :General Programming Platform :All Product :BDE 16 bit Description: "Setting the number of file handles for Borland Database Engine Applications" Solving the Borland Database Engine (BDE) error, "Not Enough file handles" (Error 0x2502 or 9474: DBIERR_NOFILEHANDLES), is not a difficult task, but it requires an understanding of how file handles are used by DOS, Windows, and your application. At the lowest level, the number of file handles available to any application running on your computer is specified in the "FILES=nn" statement of CONFIG.SYS. For Windows running with Windows and DOS applications, a bare minimum value is 30-40. A value of 80-120 is a more realistic starting value, which you should increase according to your application's needs. When your application starts in Windows, the number of files available to it is based on the following two values: (1) The number you specify in a call to the Windows API call 'SetHandleCount' (default = 20), and (2) the number of files specified in the _NFILE_ constant in Borland's RTL source (default = 20). These two values should be the same; if they're not, the lower one will apply. When estimating the number you'll need, note that in addition to whatever files you need for the BDE and for files you want to open, a C/C++ application will open five file handles for stdin, stdout, etc., on startup. The number of file handles the BDE itself can use is specified on the System Page in the MaxFileHandles parameter of the BDE Configuration utility. It is important to realize that the number specified by MaxFileHandles is the number of file handles that the BDE will expect to receive for its own exclusive use, not for use by your application as a whole. The BDE doesn't allocate file handles on its own, it gets these from your application. Thus, if you make a call to SetHandleCount with a value of 20 and set the MaxFileHandles parameter to 20, all twenty handles may go to the BDE, leaving none for your application's other needs. To sum up, the number of file handles your BDE application will need will be the sum of 1) five standard file handles, 2) the number needed by the BDE (MaxFileHandles), and 3) the number you need for other file manipulation routines. This sum should be the number you specify in SetHandleCount, and if this total is greater than 20, you'll need to change the RTL source as well. Reference: 7/15/98 3:24:23 PM
Last Modified: 11-NOV-99