GlobalLock

2.x

  void FAR* GlobalLock(hglb)    
  HGLOBAL hglb; /* handle of memory object to lock */

The GlobalLock function returns a pointer to the given global memory object. GlobalLock increments (increases by one) the lock count of movable objects and locks the memory. Locked memory will not be moved or discarded unless the memory object is reallocated by the GlobalReAlloc function. The object remains locked in memory until its lock count is decreased to zero.

Parameters

hglb

Identifies the global memory object to be locked.

Return Value

The return value points to the first byte of memory in the global object, if the function is successful. It is NULL if the object has been discarded or an error occurs.

Comments

Each time an application calls the GlobalLock function for an object, it must eventually call the GlobalUnlock function for the object.

This function will return NULL if an application attempts to lock a memory object with a zero-byte size.

If GlobalLock incremented the lock count for the object, GlobalUnlock decrements the lock count for the object. Other functions can also affect the lock count of a memory object. For a list of these functions, see the description of the GetGlobalFlags function.

Discarded objects always have a lock count of zero.

See Also

GlobalFlags, GlobalReAlloc, GlobalUnlock