Differences
This shows you the differences between two versions of the page.
| en:docs:win16:api:kernel:locallock [2023/05/01 10:43] – created prokushev | en:docs:win16:api:kernel:locallock [2026/03/04 05:02] (current) – prokushev | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| {{page> | {{page> | ||
| - | ====== | + | ====== |
| + | ==== Brief ==== | ||
| + | Locks a local memory object and returns a pointer to its first byte. | ||
| - | ===== Brief ===== | + | ==== Syntax |
| + | <code c>LPVOID WINAPI LocalLock( | ||
| + | HLOCAL hMem | ||
| + | );</ | ||
| - | ===== Syntax ===== | + | ==== Parameters |
| - | ===== Parameters ===== | + | hMem – Handle to the memory object. |
| - | ===== Return | + | ==== Return |
| - | ===== Notes ===== | + | Returns a pointer to the beginning of the memory block. |
| - | ===== Example Code ===== | + | Returns NULL on failure (e.g., handle is invalid or the block has been discarded). Call GetLastError. |
| - | ==== C Binding | + | ==== Notes ==== |
| + | Increments the lock count of the object by one. The heap manager cannot move or discard a locked block. | ||
| + | |||
| + | Every call to LocalLock must be balanced with a call to LocalUnlock. | ||
| + | |||
| + | For fixed objects (LMEM_FIXED), | ||
| + | |||
| + | ==== Example Code ==== | ||
| + | ==== C Binding ==== | ||
| + | <code c>LPSTR pData = (LPSTR)LocalLock(hMem); | ||
| + | if (pData) { | ||
| + | // work with data | ||
| + | LocalUnlock(hMem); | ||
| + | }</ | ||
| ==== MASM Binding ==== | ==== MASM Binding ==== | ||
| + | <code asm>push hMem | ||
| + | call LocalLock | ||
| + | mov [p], ax</ | ||
| + | |||
| + | ==== See also ==== | ||
| + | |||
| + | * [[LocalUnlock]] | ||
| + | * [[LocalHandle]] | ||
| - | ===== See also ===== | ||
| {{page> | {{page> | ||




