Detecting DirectX Versions

You can determine which version of DirectX is installed on a system by querying for various DirectX object interfaces. The GetDXVersion sample function from the GetDXVersion.cpp file in the \SDK\Samples\Misc directory performs this task for you. The function creates a few key DirectX objects — a DirectDraw object, a DirectDrawSurface object, and a DirectInput object — then queries for interfaces that were introduced in previous releases of DirectX. The function determines which version of DirectX is installed on a system and the installed operating system by using a simple process of elimination.

If you have previous versions of the DirectX documentation on your system, make sure you do not have those files in your include path or library (.LIB) path. Inadvertently linking with DirectX 3 libraries after compiling with DirectX 5 header files will cause your application to behave unpredictably.