Locks

Before you can use a surface you must lock it to prevent other readers & writers from accessing it. You can lock whole surface or just a rectangular area.

Lock( lpDestRect,            // ptr to area to lock, NULL lock entire surface
          lpDDSurfaceDesc,  // ptr to surface struct
          dwFlags,                // request flags
          hEvent);                 // NULL

Flags

Flag value
Meaning
DDLOCK_READONLY lock for read only
DDLOCK_SURFACEMEMORYPTR return ptr to top of specified RECT
DDLOCK_WAIT if busy, keep trying to obtain lock until you get it
DDLOCK_WRITEONLY lock & enable write

To unlock the area:

Unlock(lpRect); // lpRect is the area you locked or NULL for whole surface

EX: lpddsPrimary -> Unlock(NULL);