_HUnLock( ) API Library Routine
Unlocks a memory handle so that Visual FoxPro can access it during memory reorganization.
void _HUnLock(MHANDLE hand)
MHANDLE hand; /* Memory handle. /
Remarks
_HUnLock( ) doesn't cause memory reorganization.
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 _RetDateStr( ) to return a Visual FoxPro date type, assuming that the character parameter is a proper date. It issues _HUnLock( ) when memory handles no longer need to be locked, because the performance of Visual FoxPro can be adversely affected by locked memory handles.
Visual FoxPro Code
SET LIBRARY TO HUNLOCK
? DATES("2/16/95") && returns date {02/16/95}
C Code
#include <pro_ext.h>
void FAR dates(ParamBlk FAR *parm)
{
MHANDLE mh;
char FAR *instring;
if ((mh = _AllocHand(parm->p[0].val.ev_length + 1)) == 0)
{
_Error(182); // "Insufficient memory"
}
_HLock(parm->p[0].val.ev_handle);
instring = _HandToPtr(parm->p[0].val.ev_handle);
instring[parm->p[0].val.ev_length] = '\0';
_RetDateStr(instring);
_HUnLock(parm->p[0].val.ev_handle);
}
FoxInfo myFoxInfo[] = {
{"DATES", (FPFI) dates, 1, "C"}
};
FoxTable _FoxTable = {
(FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};
See Also
Reference
_AllocHand( ) API Library Routine
_FreeHand( ) API Library Routine
_GetHandSize( ) API Library Routine
_HandToPtr( ) API Library Routine
_MemAvail( ) API Library Routine
_SetHandSize( ) API Library Routine