HANDLE LockSegment(wSegment)
This function locks the segment whose segment address is specified by the wSegment parameter. If wSegment is –1, the LockSegment function locks the current data segment.
Except for nondiscardable segments in protected (standard or 386 enhanced) mode, the segment 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 a portion of the segment is being reallocated by the GlobalReAlloc function. The segment remains locked in memory until its lock count is decreased to zero.
In protected mode, LockSegment increments the lock count of discardable and automatic data segments only.
Each time an application calls LockSegment for a segment, it must eventually call UnlockSegment for the segment. The UnlockSegment function decreases the lock count for the segment. 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 |
wSegment | WORD Specifies the segment address of the segment to be locked. If wSegment is –1, the LockSegment function locks the current data segment. |
The return value identifies the data segment if the function is successful. If the object has been discarded or an error occurs, the return value is NULL.