DosSetMaxFH

Defines the maximum number of file handles for the calling process.

Syntax
DosSetMaxFH(cFH)

Parameters

 * cFH (ULONG) - input : Total number of file handles to be provided.

Return Code

 * ulrc (APIRET) - returns:DosSetMaxFH returns one of the following values:
 * 0 NO_ERROR
 * 8 ERROR_NOT_ENOUGH_MEMORY
 * 87 ERROR_INVALID_PARAMETER

Remarks
OS/2 initially allocates 50 file handles to a process. This is the recommended number for an application. However, if the system limit has not been reached, this amount can be increased with DosSetMaxFH. When DosSetMaxFH is issued, all open file handles are preserved.

If an application tries to set the number of file handles using DosSetMaxFH to a value less than the number of file handles set by OS/2 or a parent process it will return an error return code of 87, ERROR_INVALID_PARAMETER. If a higher limit is set, it can be lowered, but not lower than the value inherited from the system or the parent process.

Applications should instead use DosSetRelMaxFH, to query first and then to set, the maximum number of file handles for a process.

Example Code
This example defines and adjust the maximum number of file handles. 
 * 1) define INCL_DOSFILEMGR     /* File Manager values */
 * 2) define INCL_DOSERRORS      /* DOS Error values */
 * 3) include 
 * 4) include 

int main(VOID){ ULONG   CurMaxFH      = 0;          /* Current count of handles         */ LONG    ReqCount      = 0;          /* Number to adjust file handles    */ APIRET  rc            = NO_ERROR;   /* Return code                      */

rc = DosSetRelMaxFH(&ReqCount,    /* Using 0 here will return the       */                      &CurMaxFH);    /* current number of file handles     */

if (rc != NO_ERROR) { printf("DosSetRelMaxFH error: return code = %u\n", rc); return 1; } else { printf("Maximum number of file handles is %u.\n", CurMaxFH); }

rc = DosSetMaxFH(110L);           /* Set maximum file handles to 110  */

if (rc != NO_ERROR) { printf("DosSetMaxFH error: return code = %u\n", rc); return 1; }

ReqCount = -5L;                   /* Want 5 less file handles         */ rc = DosSetRelMaxFH(&ReqCount,&CurMaxFH);    /* Change handle maximum */

if (rc != NO_ERROR) { printf("DosSetRelMaxFH error: return code = %u\n", rc); return 1; } else { printf("Maximum number of file handles is now %u.\n", CurMaxFH); } return NO_ERROR; } 

Related Functions

 * DosDupHandle
 * DosOpen
 * DosSetRelMaxFH