Changes the size of a specified global memory object.

ReAllocHGlobal(nHandle, nNumberOfBytes [, nFlags])

Parameters

nHandle

A handle to a memory block returned from AllocHGlobal.

nNumberOfBytes

The new size of the memory block.

nFlags (optional)

default = GMEM_ZEROINIT

The reallocation options.

If GMEM_MODIFY is specified, the function modifies the attributes of the memory object only (the nNumberOfBytes parameter is ignored.) Otherwise, the function reallocates the memory object.

You can optionally combine GMEM_MODIFY with the following value.

FlagDescription
GMEM_MOVEABLE Allocates movable memory.

If the memory is a locked GMEM_MOVEABLE memory block or a GMEM_FIXED memory block and this flag is not specified, the memory can only be reallocated in place.


If this parameter does not specify GMEM_MODIFY, you can use the following value.

FlagDescription
GMEM_ZEROINITCauses the additional memory contents to be initialized to zero if the memory object is growing in size.

Return Value

A handle or a pointer to the allocated memory area.

Remarks

If ReAllocHGlobal reallocates a movable object, the return value is a handle to the memory object. To convert the handle to a pointer, use the LockHGlobal function.

If ReAllocHGlobal reallocates a fixed object, the value of the handle returned is the address of the first byte of the memory block.

If ReAllocHGlobal fails, the original memory is not freed, and the original handle and pointer are still valid.

See Also

Reference

AllocHGlobal
AllocMem
AllocMemTo
AMemBlocks
CompactMem
FreeHGlobal
FreeMem
FreePMem
FreeRefArray
LockHGlobal
ReAllocMem
SizeOfMem
UnlockHGlobal
ValidateMem

Used WinApi functions

GlobalReAlloc