DosSetRelMaxFH
Appearance
Adjusts the maximum number of file handles for the calling process.
Syntax
DosSetRelMaxFH(pcbReqCount, pcbCurMaxFH)
Parameters
- pcbReqCount (PLONG) - input
- Address of the number to be added to the maximum number of file handles for the calling process.
- If pcbReqCount is positive, the maximum number of file handles is increased. If pcbReqCount is negative, the maximum number of file handles is decreased.
- The system treats a decrease in the maximum number of file handles as an advisory request that may or may not be granted; the system may track and defer such a request.
- pcbCurMaxFH (PULONG) - output
- Address of the variable to receive the new total number of allocated file handles.
Return Code
- ulrc (APIRET) - returns
- DosSetRelMaxFH returns one of the following values:
- 0 NO_ERROR
Remarks
All file handles that are currently open are preserved. The system may defer or disregard a request to decrease the maximum number of file handles for the current process. The return code is set to NO_ERROR even if the system defers or disregards a request for a decrease.
You should examine the value of pcbCurMaxFH to determine the result of DosSetRelMaxFH.
Example Code
This example shows how to define and adjust the maximum number of file handles.
#define INCL_DOSFILEMGR /* File Manager values */ #define INCL_DOSERRORS /* DOS Error values */ #include <os2.h> #include <stdio.h> 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; }