GlobalLock函数 |
The GlobalLock function locks a global memory object and returns a pointer to the first byte of the object's
memory block.
GlobalLock函数将一个全局内存对象锁定,并返回该块内存首字节指针 Note Therefore, new applications should use the heap functions. However, the global functions are still used with DDE and the clipboard functions. 注意 LPVOID GlobalLock( Parameters function. Return Values If the function fails, the return value is NULL. To get extended error information, call GetLastError.
Remarks
The internal data structures for each memory object include a lock count that is initially zero. For movable memory objects, GlobalLock increments the count by one, and the GlobalUnlock function decrements the count by one. For each call that a process makes to GlobalLock for an object, it must eventually call GlobalUnlock.
Locked memory will not be moved or discarded, unless the memory object is reallocated by using the
GlobalReAlloc function. The memory block of a locked memory object remains locked until its lock count is
decremented to zero, at which time it can be moved or discarded.
备注 Memory objects allocated with GMEM_FIXED always have a lock count of zero. For these objects, the value of the returned pointer is equal to the value of the specified handle. 以GMEM_FIXED属性开辟的内存块空间的计数器始终为0,对于这样的对象,函数的返回指针值即为该句柄值。 If the specified memory block has been discarded or if the memory block has a zero-byte size, this function returns NULL.
如果指定的内存块已经被释放或者大小为0字节,该函数将返回NULL。
Discarded objects always have a lock count of zero. 释放后的对象的计数器为0。 |