Checking graphics driver version using registry keys

I am developing Windows installer with NSIS. When the installer starts, I want to check the version of NVIDIA graphic driver. What is the right way to check it? I am currently using registry key “SYSTEM\CurrentControlSet\Control\Class{4D36E968-E325-11CE-BFC1-08002BE10318}\0000” (HKEY_LOCAL_MACHINE). It works well for most of cases, but I found a system whose driver version is located in “SYSTEM\CurrentControlSet\Control\Class{4D36E968-E325-11CE-BFC1-08002BE10318}\0004”

Looks like you can determine which class to use by using a multi-step process:

  • check “HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\VIDEO” to get a reference to the control set to look at.
  • check “{key from prev. step}\video\Driver” to get the class to examine
  • check “HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class{class from last step}\0000\DriverVersion” to get the version number of the driver.

What I’m not clear on (and why I ended up looking at this question) is: In the first step there are multiple ‘Video’ options, where x is an int incrementing from 0 - which one should I choose? The code I’m looking at currently just gets the largest increment (as given by “HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class\MaxObjectNumber”) which is not always correct.

Given the age of the OP, I’m hoping you have already resolved your issue and may be able to provide some insight.