GlobalUnlock

 

Description

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.

Syntax

BOOL GlobalUnlock( HGLOBAL hMem )

Parameters

hMem
[input] Handle to the global memory object.

Return

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.

Examples

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);
}

Remark

See Also

GlobalReAlloc, GlobalReAlloc, GlobalFree, GlobalSize, GlobalLock

header to Include

origin.h

Reference