如何检测已安装的 DirectX 版本

How to detect installed versions of DirectX

我正在开发一个应用程序来检测我系统上安装的 DirectX 版本。例如,如果我的系统上安装了 DirectX 9 和 DirectX 11,那么我的程序必须检测这些安装并显示安装的版本。但我不知道如何完成这个

编辑: 我不想使用 dxdiag UI 来检测版本,我希望我的程序检测版本。并且必须检测所有已安装的版本,而不仅仅是预装 OS 的版本或 OS

支持的最高版本

您很可能无法列出 所有 已安装的 DirectX 版本。我遇到了 this interesting article in the support pages of the gaming platform called Steam:

Trying to manually check for the correct versions is extremely complicated because there are numerous files that must all be present and individual system configuration options like dll search paths complicate the situation. In addition, the dependencies and required checks may change in each new version of the D3DX runtime.

作为你可以通过运行获取最高安装版本dxdiag /x <output file>生成一个XML文件包含你的电脑信息的各种条目,然后解析或反序列化该文件在您的应用程序中。