DosSetRelMaxFH: Difference between revisions
Appearance
Created page with "==Description== Adjusts the maximum number of file handles for the calling process. ==Syntax== <PRE> #define INCL_DOSFILEMGR #include <os2.h> PLONG pcbReqCount; /* Add..." |
mNo edit summary |
||
Line 12: | Line 12: | ||
ulrc = DosSetRelMaxFH(pcbReqCount, pcbCurMaxFH); | ulrc = DosSetRelMaxFH(pcbReqCount, pcbCurMaxFH); | ||
</PRE> | |||
==Parameters== | ==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. | |||
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. | |||
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== | ==Return Code== | ||
ulrc (APIRET) - returns | ulrc (APIRET) - returns | ||
DosSetRelMaxFH returns one of the following values: | DosSetRelMaxFH returns one of the following values: | ||
*0 NO_ERROR | |||
* 0 | |||
==Remarks== | ==Remarks== | ||
Line 37: | Line 32: | ||
==Example Code== | ==Example Code== | ||
This example shows how to define and adjust the maximum number of file handles. | This example shows how to define and adjust the maximum number of file handles. | ||
<PRE> | <PRE> | ||
#define INCL_DOSFILEMGR /* File Manager values */ | #define INCL_DOSFILEMGR /* File Manager values */ | ||
#define INCL_DOSERRORS /* DOS Error values */ | #define INCL_DOSERRORS /* DOS Error values */ | ||
Line 81: | Line 74: | ||
return NO_ERROR; | return NO_ERROR; | ||
} | } | ||
</PRE> | |||
==Related Functions== | ==Related Functions== | ||
* [[ | * [[DosDupHandle]] | ||
* [[ | * [[DosOpen]] | ||
* [[ | * [[DosSetMaxFH]] | ||
[[Category: | [[Category:Dos]] |
Revision as of 00:33, 2 December 2016
Description
Adjusts the maximum number of file handles for the calling process.
Syntax
#define INCL_DOSFILEMGR #include <os2.h> PLONG pcbReqCount; /* Address of the number to be added to the maximum number of file handles for the calling process. */ PULONG pcbCurMaxFH; /* Address of the variable to receive the new total number of allocated file handles. */ APIRET ulrc; /* Return Code. */ ulrc = 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; }