Find out the active graphics driver using SetupAPI

≡放荡痞女 提交于 2019-12-11 06:05:41

问题


I try to find out the version of the currently active graphics driver on Windows using C++ and SetupAPI. The solution roughly looks like

  1. Call SetupDiGetClassDevs for GUID_DEVCLASS_DISPLAY.
  2. Call SetupDiBuildDriverInfoList for the result set.
  3. Call SetupDiEnumDriverInfo for the device set with SPDIT_COMPATDRIVER, which gives me all known drivers compatible with the GPU.

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?

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.


回答1:


Just FYI, you can also query the SPDRP_DRIVER via SetupDiGetDeviceRegistryProperty and then lookup that registry value under Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\. That key contains all the driver info. Here is some sample code from WebKit that actually retrieves GPU info this way.




回答2:


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.



来源:https://stackoverflow.com/questions/49796791/find-out-the-active-graphics-driver-using-setupapi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!