JavaScript Editor js editor     Web development 

Main Page

Translates a memory handle to a FAR (32-bit) pointer, which points to the memory allocated to this handle.

void FAR * _HandToPtr(MHANDLE hand)
MHANDLE hand;            /* Memory handle. */


Visual FoxPro may reorganize memory any time control is passed to it or to another routine outside of the current module.

_HandToPtr() doesn't cause memory reorganization. The pointer returned by _HandToPtr() may become invalid any time control is passed back to Visual FoxPro, unless the MHANDLE is locked. Don't keep pointers to unlocked memory handles across an external function call, unless it is documented that the call 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.


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.

Visual FoxPro Code

В Copy Code
= HANDTOPTR("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[] = {
   {"HANDTOPTR", (FPFI) Example, 1, "C"},
FoxTable _FoxTable = {
   (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo

See Also

JavaScript Editor js editor     Web development