Allocates the specified number of bytes from the global heap.

AllocHGlobal(nNumberOfBytes [, nFlags])

Parameters

nNumberOfBytes

The number of bytes to allocate.

nFlags (optional, additive)

default = GMEM_MOVEABLE | GMEM_ZEROINIT

One or a combination of the following values.
FlagDescription
GMEM_FIXEDAllocates fixed memory. The return value is a pointer.
GMEM_MOVEABLEAllocates movable memory. Memory blocks are never moved in physical memory, but they can be moved within the default heap.
The return value is a handle to the memory object. To translate the handle into a pointer, use the LockHGlobal function.
This value cannot be combined with GMEM_FIXED.
GMEM_ZEROINITInitializes memory contents to zero.

Return Value

Either a pointer or handle to the allocated memory depending on the nFlags parameter.

See Also

Reference

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

Used WinApi functions

GlobalAlloc