The GlobalDiscard function discards the specified global memory block. The lock count of the memory object must be zero.
HGLOBAL GlobalDiscard(
HGLOBAL hglbMem |
// handle to the global memory object |
); |
If the function succeeds, the return value is the handle of the memory object.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.
GlobalDiscard discards only global objects that the calling process allocated with the GMEM_DISCARDABLE flag. If a process attempts to discard a fixed or locked object, the function fails.
Although GlobalDiscard discards the object’s memory block, the handle of the object remains valid. A process can subsequently pass the handle to the GlobalReAlloc function to allocate another global memory block identified by the same handle.