The IDirectDrawSurface4::Lock method obtains a pointer to the surface memory.
HRESULT Lock(
LPRECT lpDestRect,
LPDDSURFACEDESC2 lpDDSurfaceDesc,
DWORD dwFlags,
HANDLE hEvent
);
If the method succeeds, the return value is DD_OK.
If the method fails, the return value may be one of the following error values:
DDERR_INVALIDOBJECT |
DDERR_INVALIDPARAMS |
DDERR_OUTOFMEMORY |
DDERR_SURFACEBUSY |
DDERR_SURFACELOST |
DDERR_WASSTILLDRAWING |
For more information on using this method, see Accessing Surface Memory Directly.
After retrieving a surface memory pointer, you can access the surface memory until a corresponding IDirectDrawSurface4::Unlock method is called. When the surface is unlocked, the pointer to the surface memory is invalid.
Do not call DirectDraw blit functions to blit from a locked region of a surface. If you do, the blit returns either DDERR_SURFACEBUSY or DDERR_LOCKEDSURFACES. Additionally, GDI blit functions will silently fail when used on a locked video memory surface.
Unless you include the DDLOCK_NOSYSLOCK flag, this method causes DirectDraw to hold the Win16Mutex (also known as Win16Lock) until you call the IDirectDrawSurface4::Unlock method. GUI debuggers cannot operate while the Win16Mutex is held.
Windows NT/2000: Requires Windows 2000.
Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.
Header: Declared in ddraw.h.
Import Library: Use ddraw.lib.
IDirectDrawSurface4::Unlock, IDirectDrawSurface4::GetDC, IDirectDrawSurface4::ReleaseDC