The GlobalReAlloc function changes the size or attributes of a specified global memory object. The size can increase or decrease.
HGLOBAL GlobalReAlloc( HGLOBAL hMem, DWORD dwBytes, UINT uFlags )
If the function succeeds, the return value is a handle to the reallocated memory object.
If the function fails, the return value is NULL.
EX1
void GlobalReAlloc_Ex1() { DWORD nMemSize =200 ; HGLOBAL hData = GlobalAlloc(GHND,nMemSize); if(!hData) { out_str("failed to allocate memory\n"); return ; } if(NULL == GlobalReAlloc(hData, nMemSize*2, GMEM_MOVEABLE)) { out_str("failed to Reallocate memory\n"); return ; } else { printf("The memory resized to : %d BYTES",GlobalSize(hData)) ; } GlobalFree(hData) ; }
GlobalAlloc, GlobalFree, GlobalSize, GlobalLock, GlobalUnlock
origin.h