The GlobalHandle function retrieves the handle of the specified global memory object.
HGLOBAL GlobalHandle( LPVOID pMem )
If the function succeeds, the return value is the Handle of the specified global memory object, in bytes.
EX1
void GlobalHandle_Ex1() { int nBytes = 200; HGLOBAL hData = GlobalAlloc(GHND,nBytes); char* pstr = (char *)GlobalLock(hData) ; if(NULL==pstr) { out_str("failed to Lock the memory\n"); return ; } HGLOBAL hDataTemp = GlobalHandle(pstr) ; if(0==GlobalUnlock(hDataTemp)) out_str("the memory has been unlocked sucessfuly\n"); GlobalFree(hDataTemp) ; }
When the GlobalAlloc function allocates a memory object with GMEM_MOVEABLE, it returns a handle to the object. The GlobalLock function converts this handle into a pointer to the memory block, and GlobalHandle converts the pointer back into a handle.
GlobalReAlloc, GlobalReAlloc, GlobalFree, GlobalLock, GlobalUnlock
origin.h