GlobalLock

  LPVOID 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 block 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. Use the GetLastError function to obtain extended error information.

Comments

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

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

Discarded objects always have a lock count of zero.

See Also

GlobalFlags, GlobalReAlloc, GlobalUnlock