JavaScript Editor js editor     Web development 

Main Page

Locks a memory handle to prevent it from moving if Visual FoxPro requires memory reorganization.

void _HLock(MHANDLE hand)
MHANDLE hand;            /* Memory handle. */


_HLock(В ) doesn't cause memory reorganization. Unlock the MHANDLE as soon as the lock has served its purpose.

For more information on how to create an API library and integrate it with Visual FoxPro, see Accessing the Visual FoxPro API.


The following example displays its character parameter on the screen. It uses _HandToPtr(В ) to translate the memory handle of the API parameter to a C pointer. Because Visual FoxPro may decide to reorganize memory during the call to _PutStr(В ), to insure proper execution, the example locks the memory handle with _HLock(В ). The example also calls _HUnLock(В ) at the end, because the performance of Visual FoxPro can be adversely affected by locked memory handles.

Visual FoxPro Code

В Copy Code
= HLOCK("Hello, world.") && displays "Hello, world" on screen

C Code

В Copy 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)

FoxInfo myFoxInfo[] = {
   {"HLOCK", (FPFI) Example, 1, "C"},
FoxTable _FoxTable = {
   (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo

See Also

JavaScript Editor js editor     Web development