windows 如何确定安装的是哪个版本的 Direct3D?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/79745/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 11:13:00  来源:igfitidea点击:

How to determine which version of Direct3D is installed?

c++windowsdirect3d

提问by David Dibben

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.

我们有一个需要使用 Direct3D 的应用程序。具体来说,它至少需要 DirectX 9.0c 版本 4.09.0000.0904。虽然这应该存在于所有较新的 XP 机器上,但它可能不会安装在较旧的 XP 机器上。如何以编程方式(使用 C++)确定它是否已安装?我希望能够向用户提供 Direct3D 将不可用的信息消息。

回答by

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

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

You'll need to include dsetup.h

您需要包含 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));
}

回答by Adam Mitz

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

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

回答by kooshmoose

A quick Google search turns up this articlewhich 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.

在 Google 上快速搜索会找到这篇文章,它标识了版本号在注册表中的位置,然后提供了一个 case 语句,将内部版本号映射到我们更熟悉的版本号。

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

另一个快速的 Google 搜索在 C++ 中找到了一个用于从注册表读取的示例。

Enjoy...

享受...

回答by legalize

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

是的,使用 2009 年 3 月 DirectX SDK 中 DirectX 安装示例中显示的机制。(查看示例浏览器中的“系统”类别。)

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.

唯一受支持的方法是使用 DirectSetup API,如 DirectX 安装示例中所示。我也在我的书The Direct3D Graphics Pipeline中的第 24 章安装和设置中介绍了这些内容。您可以从上述 URL 免费下载该章节。