Changes the amount of memory allocated to the memory block handle hand.
unsigned short _SetHandSize(MHANDLE hand, unsigned long size) MHANDLE hand; /* Memory block handle. */ unsigned int size; /* New number of bytes. */ |
Remarks
_SetHandSize(В ) returns True (an integer other than 0) if the reallocation is successful, or False (0) if the reallocation fails. The data associated with the MHANDLE is preserved. If hand is a locked MHANDLE, _SetHandSize(В ) fails.
For more information on how to create an API library and integrate it with Visual FoxPro, see Accessing the Visual FoxPro API.
Example
The following example uses _SetHandSize(В ) to change the amount of memory allocated to an MHANDLE.
Visual FoxPro Code
В | ![]() |
---|---|
SET LIBRARY TO SETHANDS = HANDTOPTR("Hello, world.") && displays "Hello, world" on screen |
C Code
В | ![]() |
---|---|
#include <pro_ext.h> void NullTerminate(Value FAR *cVal) { if (!_SetHandSize(cVal->ev_handle, cVal->ev_length + 1)) { _Error(182); // "Insufficient memory" } ((char FAR *) _HandToPtr(cVal->ev_handle))[cVal->ev_length] = '\0'; } FAR Example(ParamBlk FAR *parm) { NullTerminate(&parm->p[0].val); _HLock(parm->p[0].val.ev_handle); _PutStr(_HandToPtr(parm->p[0].val.ev_handle)); _HUnLock(parm->p[0].val.ev_handle); } FoxInfo myFoxInfo[] = { {"HANDTOPTR", (FPFI) Example, 1, "C"}, }; FoxTable _FoxTable = { (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo }; |