The GlobalUnlock function decrements the lock count associated with a memory object that was allocated with GMEM_MOVEABLE. This function has no effect on memory objects allocated with GMEM_FIXED.
BOOL GlobalUnlock( HGLOBAL hMem )
If the memory object is still locked after decrementing the lock count, the return value is a nonzero value.
If the function fails, the return value is zero.
EX1
void GlobalUnLock_Ex1() { int nBytes = 200; HGLOBAL hData = GlobalAlloc(GHND,nBytes); char* pstrA = (char *)GlobalLock(hData) ; if(NULL==pstrA) { out_str("failed to Lock the memory\n"); return ; } char* pstrB=(char *)GlobalLock(hData) ; if(NULL==pstrB) { out_str("failed to Lock the memory\n"); return ; } if(0!=GlobalUnlock(hData)) { out_str("The memory is still locked as inferenced by other object"); if(0==GlobalUnlock(hData)) { out_str("The memory has been unlocked"); } } GlobalFree(hData); }
GlobalReAlloc, GlobalReAlloc, GlobalFree, GlobalSize, GlobalLock
origin.h