LPSTR GlobalLock(hMem)
This function retrieves a pointer to the global memory block specified by the hMem parameter.
Except for nondiscardable objects in protected (standard or 386 enhanced) mode, the block is locked into memory at the given address and its lock count is increased by one. Locked memory is not subject to moving or discarding except when the memory block is being reallocated by the GlobalReAlloc function. The block remains locked in memory until its lock count is decreased to zero.
In protected mode, GlobalLock increments the lock count of discardable objects and automatic data segments only.
Each time an application calls GlobalLock for an object, it must eventually call GlobalUnlock for the object. The GlobalUnlock function decreases the lock count for the object if GlobalLock increased the lock count for the object. Other functions also can affect the lock count of a memory object. See the description of the GlobalFlags function for a list of the functions that affect the lock count.
Parameter | Type/Description |
hMem | HANDLE Identifies the global memory block to be locked. |
The return value points to the first byte of memory in the global block if the function is successful. If the object has been discarded or an error occurs, the return value is NULL.
Discarded objects always have a lock count of zero.