Platform SDK: DirectX |
The information in this topic pertains only to applications written in C++.
Use the DirectDrawEnumerateEx function to enumerate devices on systems with multiple monitors, specifying flags to determine what types of DirectDraw devices should be enumerated. The function calls an application-defined DDEnumCallbackEx function for each enumerated device.
The DirectDrawEnumerateEx function is supported on Windows 98 and Windows 2000 operating systems. It is available in Ddraw.lib for applications compiled under DirectX 6.0 and later versions. Applications that statically link to the function will always run under DirectX 6.0 and later, and will always run under any version of DirectX on Windows 98 and Windows 2000. Such applications will fail if run on previous versions of DirectX under Windows 95.
If your application needs to run on versions of DirectX older than DirectX 5.0, it should use GetProcAddress to see if DirectDrawEnumerateEx is available. The following example shows one way you can do this.
HINSTANCE h = LoadLibrary("ddraw.dll"); // If ddraw.dll doesn't exist in the search path, // then DirectX probably isn't installed, so fail. if (!h) return FALSE; // Note that you must know which version of the // function to retrieve (see the following text). // For this example, we use the ANSI version. LPDIRECTDRAWENUMERATEEX lpDDEnumEx; lpDDEnumEx = (LPDIRECTDRAWENUMERATEEX) GetProcAddress(h,"DirectDrawEnumerateExA"); // If the function is there, call it to enumerate all display // devices attached to the desktop, and any non-display DirectDraw // devices. if (lpDDEnumEx) lpDDEnumEx(Callback, NULL, DDENUM_ATTACHEDSECONDARYDEVICES | DDENUM_NONDISPLAYDEVICES ); else { /* * We must be running on an old version of DirectDraw. * Therefore MultiMon isn't supported. Fall back on * DirectDrawEnumerate to enumerate standard devices on a * single-monitor system. */ DirectDrawEnumerate(OldCallback,NULL); /* Note that it could be handy to let the OldCallback function * be a wrapper for a DDEnumCallbackEx. * * Such a function would look like: * BOOL FAR PASCAL OldCallback(GUID FAR *lpGUID, * LPSTR pDesc, * LPSTR pName, * LPVOID pContext) * { * return Callback(lpGUID,pDesc,pName,pContext,NULL); * } */ } // If the library was loaded by calling LoadLibrary(), // then you must use FreeLibrary() to let go of it. FreeLibrary(h);
The previous example will work for applications that link to Ddraw.dll at run time or load time.
Note that you must retrieve the address of either the ANSI or Unicode version of the DirectDrawEnumerateEx function, depending of the type of strings your application uses. When declaring the corresponding callback function, use the LPTSTR data type for the string parameters. The LPTSTR data type compiles to use Unicode strings if you declare the _UNICODE symbol, and ANSI strings otherwise. By using the LPTSTR data type, the function should compile properly regardless of the string type you use in your application.