Retrieve Video (Nvidia/ATI) Driver Version

Does anyone have any suggestions on the best way to programmatically (C++) retrieve the video (nvidia/ati) driver version installed on a machine?

Currently I am using WMI queries to ask for the Win32_VideoController and then taking the “DriverVersion” and “AdapterRam” from there. For the most part this seems to retrieve accurate information.

However on some systems (particularly WinXp it seems) the driver version it returns is often “null” and/or a static file version number that never changes (no matter which driver you install). This is undesirable.

Does anyone know of a better way to get the driver version number?

Not sure about Windows methods, but on Linux here are some options:

  • nvidia-settings -q NVidiaDriverVersion (or just run and look at GUI)
  • Look at the “OpenGL version string” in glxinfo output
  • Use libXNVCtrl and query NV_CTRL_STRING_NVIDIA_DRIVER_VERSION (see below for an example)
  • Look at /proc/driver/nvidia/version (slightly ugly)
  • Look in /var/log/Xorg.0.log (really ugly)

  char *driver_name;
  XNVCTRLQueryStringAttribute( dpy, scr, 0, 
                               NV_CTRL_STRING_NVIDIA_DRIVER_VERSION,
                               &driver_name );
  printf( "GPU Driver     = %s
", driver_name );

If you’re happy to live in Windows-only land you could create a Direct3D object (before initializing OpenGL) and query that, but I don’t think it’ll give you exactly the info you’re looking for. Something like this is all you need anyway:

D3DADAPTER_IDENTIFIER9 adapterinfo;
LPDIRECT3D9 d3d_Object;

d3d_Object = Direct3DCreate9 (D3D_SDK_VERSION);
d3d_Object->GetAdapterIdentifier (D3DADAPTER_DEFAULT, 0, &adapterinfo);
d3d_Object->Release ();

Then check the members of your adapterinfo struct.

My XP system stores the driver version in the registry under:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control
Class{4D36E968-E325-11CE-BFC1-08002BE10318)\0000\DriverVersion

This gives the driver version in the long format (6.14.12.5896), where the last 5 digits is the same as the short format (258.96) that NVIDIA usually quotes.

If OpenCL support is included in the driver then you can call clGetDeviceInfo with the CL_DRIVER_VERSION enum.

Another possibility is to get the name of the driver file from:
SOFTWARE\Microsoft\Windows NT\CurrentVersion\OpenGLDrivers\RIVATNT\dll
and then use GetFileVersionInfo/VerQueryValue to query the version.

Thanks for the suggestions guys.

Dark Photon - Most of our customers are on Windows, some on the Mac… none on Linux :frowning: (although we dev guys keep a linux port)

mhagain - I had thought about doing that, at least for information such as Adapter ram (OpenGL/DirectX… no matter its the same ram).

Simon Arbon - I had thought about checking the registry but it seems that some systems don’t have that key? I found a Microsoft page mentioning that key as reserved for Video adapters though so at least I can search for it and if it is there I can use it (and if not then fall back on the WMI query).