IDirectDraw7::EnumSurfaces method

Enumerates all the existing or possible surfaces that meet the specified surface description.


HRESULT EnumSurfaces(
  DWORD                     ,
  LPVOID                    ,



A combination of one search type flag and one matching flag. The search type flag determines how the method searches for matching surfaces; you can search for surfaces that can be created using the description in the lpDDSD2 parameter or for existing surfaces that already match that description. The matching flag determines whether the method enumerates all surfaces, only those that match, or only those that do not match the description in the lpDDSD2 parameter.

Search type flags


Enumerates the first surface that can be created and meets the search criterion. This flag can be used only with the DDENUMSURFACES_MATCH flag.


Enumerates the already existing surfaces that meet the search criterion.

Matching flags


Enumerates all surfaces that meet the search criterion. This flag can be used only with the DDENUMSURFACES_DOESEXIST search type flag.


Searches for any surface that matches the surface description.


Searches for any surface that does not match the surface description.


Address of a DDSURFACEDESC2 structure that defines the surface of interest. This parameter can be NULL if dwFlags includes the DDENUMSURFACES_ALL flag.


Address of an application-defined structure to be passed to each enumeration member.


Address of the EnumSurfacesCallback7 function that the enumeration procedure calls every time a match is found.

Return value

If the method succeeds, the return value is DD_OK.

If it fails, the method can return one of the following error values:



If the DDENUMSURFACES_CANBECREATED flag is set, this method attempts to temporarily create a surface that meets the search criterion.

When you use the DDENUMSURFACES_DOESEXIST flag, an enumerated surface's reference count is incremented—if you are not going to use the surface, be sure to use IDirectDrawSurface7::Release to release it after each enumeration. If you will be using the surface, release it when it is no longer needed.

This method differs from its counterparts in previous interface versions in that it accepts a pointer to an EnumSurfacesCallback7 function, rather than an EnumSurfacesCallback or EnumSurfacesCallback2 function.

You must use LoadLibrary to explicitly link to Ddraw.dll and then use GetProcAddress to access the IDirectDraw7::EnumSurfaces method.


Target Platform Windows
Header ddraw.h
Library Ddraw.lib
DLL Ddraw.dll

See also