c++winapisetupapi

Find out the active graphics driver using SetupAPI


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.


Solution

  • 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.