GlobalDiscard

  HANDLE GlobalDiscard(hMem)    
  HANDLE hMem; /* handle of block to discard */

The GlobalDiscard function discards the specified global memory block. The lock count of the memory block must be zero.

Parameters

hMem

Identifies the global memory block to be discarded. This handle must have been created by a previous call to the GlobalAlloc or GlobalReAlloc function.

Return Value

The return value identifies the discarded block if the function is successful. Otherwise, the return value is zero. Use the GetLastError function to obtain extended error information.

Comments

The GlobalDiscard function discards only global objects that an application allocated with the GMEM_DISCARDABLE flag set. The function fails if an application attempts to discard a fixed or locked object.

Although GlobalDiscard removes the global memory object from memory, the object's handle remains valid. An application can subsequently pass the handle to the GlobalReAlloc function to allocate another global memory object identified by the same handle.

See Also

GlobalReAlloc