使用 SetupAPI 找出活动的图形驱动程序 [英] Find out the active graphics driver using SetupAPI
问题描述
我尝试使用 C++ 和 SetupAPI 在 Windows 上找出当前活动图形驱动程序的版本.解决方案大致如下
I try to find out the version of the currently active graphics driver on Windows using C++ and SetupAPI. The solution roughly looks like
- 为
GUID_DEVCLASS_DISPLAY
调用SetupDiGetClassDevs
. - 为结果集调用
SetupDiBuildDriverInfoList
. - 为使用
SPDIT_COMPATDRIVER
设置的设备调用SetupDiEnumDriverInfo
,这为我提供了与 GPU 兼容的所有已知驱动程序.
- Call
SetupDiGetClassDevs
forGUID_DEVCLASS_DISPLAY
. - Call
SetupDiBuildDriverInfoList
for the result set. - Call
SetupDiEnumDriverInfo
for the device set withSPDIT_COMPATDRIVER
, which gives me all known drivers compatible with the GPU.
结果包括来自 Microsoft 的回退驱动程序,我可以轻松排除它,但它也包括系统上已安装的所有驱动程序版本(来自 NVIDIA).
The result includes the fallback driver from Microsoft, which I can easily exclute, but it also includes all driver versions (from NVIDIA) that have been installed on the system.
问题是:我如何找出哪些驱动程序实际在运行?
The question is: How do I find out which of the drivers is actually running?
我从第 1 步返回的 SP_DEVINFO_DATA
中知道驱动程序服务是如何调用的,并且我还获得了某种注册表项,但我不知道如何将其与 相关联SP_DRVINFO_DATA
.我也知道 NVAPI 提供驱动程序管理功能,但我更喜欢适用于各种供应商的 GPU 的解决方案.
I know from the SP_DEVINFO_DATA
returned in step 1 how the driver service is called and I also get some kind of registry key, but I do not see how I could relate this to the SP_DRVINFO_DATA
. I also know that NVAPI provides driver management capabilities, but I would prefer a solution that works with GPUs of all kinds of vendors.
推荐答案
我在此期间找到了解决方案 为什么SetupDiEnumDriverInfo 给我的驱动程序提供两个版本号:需要更新DI_FLAGSEX_INSTALLEDDRIVER
设置的设备信息的安装参数在第 3 步之前标记.
I found the solution in the meantime at Why does SetupDiEnumDriverInfo give two version numbers for my driver: You need to update the install parameters of the device information set with the DI_FLAGSEX_INSTALLEDDRIVER
flag before step 3.
这篇关于使用 SetupAPI 找出活动的图形驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!