REM PspTrick.txt describes increasing file handles.

----------2167-------------------------------
INT 21 - DOS 3.3+ - SET HANDLE COUNT
    AH = 67h
    BX = size of new file handle table for process

The above bios routine is normally used by your program to request more file
handles. Since Dos or windows will not always be able to give you more than
20 handles using interrupt &h21, the basic routine described below will.

Sub Increase.Files
 On Local Error Resume Next
 Close
 InregsX.AX=&H6200
 Call InterruptX(&H21,InregsX,OutregsX)
 PSP.Segment=OutregsX.BX
 Def Seg=PSP.Segment
 Command.Line=&H80
 Command.Tail=Command.Line+80
 For Var=1 To 36
    Poke Command.Tail+Var-1,&HFF
 Next
 For Var=1 To 5
    File.Handle=Peek(&H18+Var-1)
    Poke Command.Tail+Var-1,File.Handle
 Next
 Poke &H32,36
 Poke &H34,Command.Tail
 Def Seg
End Sub

Call this routine to give your basic program more file handles than can be
allowed by dos or windows. The first step for requesting more file handles is
to call interrupt &h62 for the segment of the psp. In the psp are located the
current maximum number of handles in the job file table, the address to the
file handles, and the file handles themselves. Since the pointer to the file
handles contains only a offset and not a segment, there must be some memory
area in the psp to store the extended file handles to be assigned. And since
there is no way of knowing what the memory areas are surrounding the psp, the
tail end of where the command line is located is used for the pointer of the
file handles, and the file handles are copied there. An offset 80 bytes from
where the command line is stored is used. This is reasonable if your command
line is less than 80 characters. Next, the default file handles which are
closed are copied to the offset pointed to the command tail plus 36 files,
with &hff indicating the handles. Then, the current file handles are copied
to the command tail. And finally, the psp jtf updated with the new maximum of
file handles, and the pointer to the offset to the command tail containing the
new jft memory area.

After this routine is called by your program when it first starts, the psp is
the resident memory area containing the new jft. Notice however that the
routine must be called each time your program is chained to, and the close
statement must be used before increasing the psp. If you do not use the basic
chain statement, you should not have to reassign the psp parameters. Note also
that since the file handles are more than interrupt &h21 would allow, the
bios will close all file handles with the close statement anyway by counting
the file handles assigned. And finally note that the maximum number of file
handles assigned are added to the number of file handles opened by other
processes in windows, and are used by the global windows handles count.

Note: Although Dos uses 4 file handles for the operating system (cons:, scrn:,
   pipe:, kybd:), the Basic CHAIN statement uses one more file handle. So,
   when copying the file handles, subtract 5 from the number allocated.

-end-
