DosSetRelMaxFH: Difference between revisions
Appearance
m →Syntax |
mNo edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
Adjusts the maximum number of file handles for the calling process. | Adjusts the maximum number of file handles for the calling process. | ||
==Syntax== | ==Syntax== | ||
DosSetRelMaxFH(pcbReqCount, pcbCurMaxFH) | |||
==Parameters== | ==Parameters== | ||
;pcbReqCount (PLONG) - input : Address of the number to be added to the maximum number of file handles for the calling process. | ;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. | :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. | :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. | ;pcbCurMaxFH (PULONG) - output: Address of the variable to receive the new total number of allocated file handles. | ||
==Return Code== | ==Return Code== | ||
;ulrc (APIRET) - returns:DosSetRelMaxFH returns one of the following values: | |||
DosSetRelMaxFH returns one of the following values: | |||
*0 NO_ERROR | *0 NO_ERROR | ||
Line 30: | Line 17: | ||
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. | 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. | You should examine the value of pcbCurMaxFH to determine the result of DosSetRelMaxFH. | ||
==Example Code== | ==Example Code== |
Latest revision as of 21:52, 29 November 2019
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; }