简体   繁体   中英

How to determine which version of Direct3D is installed?

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.

Call DirectXSetupGetVersion: http://msdn.microsoft.com/en-us/library/microsoft.directx_sdk.directsetup.directxsetupgetversion

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));
}

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.

根据DirectX 9.0 SDK(2004年夏季)文档,请参阅\\ Samples \\ Multimedia \\ DXMisc \\ GetDXVer中的GetDXVer SDK示例。

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...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM