Both of these functions initiate an enumeration sequence similar to other enumerations we've discussed in the book. The enumeration provides information about the DirectX-capable devices that are installed on the host system. The DirectDrawEnumerate() function relies on the DDEnumCallback() function to handle the callback. Likewise, the DirectDrawEnumerateEx() function relies on the DDEnumCallbackEx() function to handle the callback. We discuss both callback functions in the section entitled "Creating DirectX Callback Function Prototypes" later in this chapter.
Note The DirectDrawEnumerate() function is superceded by the DirectDrawEnumerateEx() function. Even though DirectX still supports the DirectDrawEnumerate() function, you should use the DirectDrawEnumerateEx() function in all new code. The example library contains a function declaration for only the DirectDrawEnumerateEx() function.
The DirectDrawEnumerateEx() function requires three arguments as input. The first is the address of a callback function. We'll create this callback as we did all of the examples in Chapter 5. This means creating a delegate and then a handler based on that delegate. The lpContext contains the address of an application-specific value that you can pass to the callback function each time DirectX calls it. Generally, you'll only use this argument if the callback function requires special data. Finally, you can pass flags in the dwFlags argument that changes the scope of the enumeration. The default value of 0 enumerates only the primary display device. The following list describes the other flag values:
DDENUM_ATTACHEDSECONDARYDEVICES Lists any display devices that are part of the Windows Desktop. For example, it would list a second display adapter but not an inactive 3D accelerator.
DDENUM_DETACHEDSECONDARYDEVICES Lists any display devices that are installed on the host system but aren't part of the Windows Desktop. For example, this flag would list an inactive 3D accelerator and other support hardware, but it won't list a second display adapter. To list all of the display devices, you must combine this flag with the DDENUM_ATTACHED-SECONDARYDEVICES flag.
DDENUM_NONDISPLAYDEVICES Lists all non-display DirectX-capable devices, but it won't list any of the display devices. If you want to list all of the DirectX-capable devices on the host system, you must combine all three flags.
Was this article helpful?