Allocates the specified number of bytes from the heap.
Note The global functions have greater overhead and provide fewer features than other memory management functions. New applications should use the heap functions unless documentation states that a global function should be used.
HGLOBAL WINAPI GlobalAlloc( _In_ UINT uFlags, _In_ SIZE_T dwBytes );
- uFlags [in]
- The memory allocation attributes. If zero is specified, the default is GMEM_FIXED. This parameter can be one or more of the following values, except for the incompatible combinations that are specifically noted.
Value Meaning GHND
Combines GMEM_MOVEABLE and GMEM_ZEROINIT. GMEM_FIXED
Allocates fixed memory. The return value is a pointer. GMEM_MOVEABLE
Allocates 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 GlobalLock function.
This value cannot be combined with GMEM_FIXED.
Initializes memory contents to zero. GPTR
Combines GMEM_FIXED and GMEM_ZEROINIT.
- The following values are obsolete, but are provided for compatibility with 16-bit Windows. They are ignored.
- dwBytes [in]
- The number of bytes to allocate. If this parameter is zero and the uFlags parameter specifies GMEM_MOVEABLE, the function returns a handle to a memory object that is marked as discarded.
If the function succeeds, the return value is a handle to the newly allocated memory object.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.