HANDLE GlobalReAlloc(hMem,dwBytes,wFlags)
This function reallocates the global memory block specified by the hMem parameter by increasing or decreasing its size to the number of bytes specified by the dwBytes parameter.
Parameter | Type/Description |
hMem | HANDLE Identifies the global memory block to be reallocated. | ||
dwBytes | DWORD Specifies the new size of the memory block. | ||
wFlags | WORD Specifies how to reallocate the global block. | ||
If the existing memory flags can be modified, use either one or both of the following flags (if both flags are specified, join them with the bitwise OR operator): | |||
Value | Meaning | ||
GMEM_DISCARDABLE | Memory can be discarded. Use only with GMEM_MODIFY. | ||
GMEM_MODIFY | Memory flags are modified. The dwBytes parameter is ignored. Use only if an application will modify existing memory flags and not reallocate the memory block to a new size. | ||
GMEM_MOVEABLE | Memory is movable. If dwBytes is zero, this flag causes an object previously allocated as moveable and discardable to be discarded if the block's lock count is zero. If the block is not moveable and discardable, the GlobalReAlloc will fail. If dwBytes is nonzero and the block specified by hMem is fixed, this flag allows the re-allocated block to be moved to a new fixed location. If a moveable object is locked, this flag allows the object to be moved. This may occur even if the object is currently locked by a previous call to GlobalLock. (Note that the handle returned by the GlobalReAlloc function in this case may be different from the handle passed to the function.) Use this flag with GMEM_MODIFY to make a fixed memory block moveable. | ||
Value | Meaning | ||
GMEM_NOCOMPACT | Memory will not be compacted or discarded in order to satisfy the allocation request. This flag is ignored if the GMEM_MODIFY flag is set. | ||
GMEM_NODISCARD | Objects will not be discarded in order to satisfy the allocation request. This flag is ignored if the GMEM_MODIFY flag is set. | ||
GMEM_ZEROINIT | If the block is growing, the additional memory contents are initialized to zero. This flag is ignored if the GMEM_MODIFY flag is set. |
The return value identifies the reallocated global memory if the function is successful.
The return value is NULL if the block cannot be reallocated.
If the function is successful, the return value is always identical to the hMem parameter, unless any of the following conditions is true:
The GMEM_MOVEABLE flag is used to allow movement of a fixed block to a new fixed location.
Windows is running in standard mode and the object is reallocated past a multiple of 65,519 bytes (16 bytes less than 64K).
Windows is running in 386 enhanced mode and the object is reallocated past a multiple of 64K.