问题
I try to find out the version of the currently active graphics driver on Windows using C++ and SetupAPI. The solution roughly looks like
- 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.
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