views:

851

answers:

4

We have an application which needs to use Direct3D. Specifically, it needs at least DirectX 9.0c version 4.09.0000.0904. While this should be present on all newer XP machines it might not be installed on older XP machines. How can I programmatically (using C++) determine if it is installed? I want to be able to give an information message to the user that Direct3D will not be available.

A: 

According to the DirectX 9.0 SDK (summer 2004) documentation, see the GetDXVer SDK sample at \Samples\Multimedia\DXMisc\GetDXVer.

Adam Mitz
+5  A: 

Call DirectXSetupGetVersion: http://msdn.microsoft.com/en-us/library/bb219716(VS.85).aspx

You'll need to include dsetup.h

Here's the sample code from the site:

DWORD dwVersion;
DWORD dwRevision;
if (DirectXSetupGetVersion(&dwVersion, &dwRevision))
{
    printf("DirectX version is %d.%d.%d.%d\n",
           HIWORD(dwVersion), LOWORD(dwVersion),
           HIWORD(dwRevision), LOWORD(dwRevision));
}
A: 

A quick Google search turns up this article which identifies the location of the version number in the registry and then provides a case statement which maps the internal version number to the version number we're more familiar with.

Another quick Google search turns up an example in C++ for reading from the registry.

Enjoy...

kooshmoose
A: 

Yes, use the mechanism shown in the DirectX Install sample in the March 2009 DirectX SDK. (Look under "System" category in the sample browser.)

Do not use the registry! That stuff is undocumented and not guaranteed to work.

The only supported way is to use the DirectSetup API, which is shown in the DirectX Install sample. I also cover this stuff in Chapter 24. Installation and Setup in my book The Direct3D Graphics Pipeline. You can download that chapter for free at the above URL.

legalize