Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Changes the size or attributes of a specified global memory object. The size can increase or decrease.
Syntax
DECLSPEC_ALLOCATOR HGLOBAL GlobalReAlloc(
[in] _Frees_ptr_ HGLOBAL hMem,
[in] SIZE_T dwBytes,
[in] UINT uFlags
);
Parameters
[in] hMem
A handle to the global memory object to be reallocated. This handle is returned by either the GlobalAlloc or GlobalReAlloc function.
[in] dwBytes
The new size of the memory block, in bytes. If uFlags specifies GMEM_MODIFY, this parameter is ignored.
[in] uFlags
The reallocation options. If GMEM_MODIFY is specified, the function modifies the attributes of the memory object only (the dwBytes parameter is ignored.) Otherwise, the function reallocates the memory object.
You can optionally combine GMEM_MODIFY with the following value.
If this parameter does not specify GMEM_MODIFY, you can use the following value.
Value | Meaning |
---|---|
|
Causes the additional memory contents to be initialized to zero if the memory object is growing in size. |
Return value
If the function succeeds, the return value is a handle to the reallocated memory object.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.
Remarks
If GlobalReAlloc reallocates a movable object, the return value is a handle to the memory object. To convert the handle to a pointer, use the GlobalLock function.
If GlobalReAlloc reallocates a fixed object, the value of the handle returned is the address of the first byte of the memory block. To access the memory, a process can simply cast the return value to a pointer.
If GlobalReAlloc fails, the original memory is not freed, and the original handle and pointer are still valid.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows XP [desktop apps | UWP apps] |
Minimum supported server | Windows Server 2003 [desktop apps | UWP apps] |
Target Platform | Windows |
Header | winbase.h (include Windows.h) |
Library | Kernel32.lib |
DLL | Kernel32.dll |