Home > OS >  Getting the max possible display rate of connected monitors
Getting the max possible display rate of connected monitors

Time:01-01

I am trying to get programmatically the maximum display rate that Windows allows (i.e, Display settings > Advanced display settings > Refresh rate > max value). Chances are, there's no such query and I instead need to obtain all the possible options. How do I do that ?

I've already obtained the monitor names and current refresh rates using the CCD API, by obtaining DISPLAYCONFIG_PATH_INFOs and by using DisplayConfigGetDeviceInfo. But I can't seem to find a way to obtain the refresh rate options associated to a monitor. A CCD API based solution would be perfect, but an alternative is fine - it just means I'll have to reconcile the information obtained via the CCD API with that obtained from that other API, somehow.

Also, I'm trying to do this in the context of a plain Windows executable, that doesn't use a specific graphics backend library (ex DX12) or game-making framework.

Thanks !

CodePudding user response:

Using the CCD API, you can use DisplayConfigGetDeviceInfo to get the GDI device name using DISPLAYCONFIG_DEVICE_INFO_TYPE::DISPLAYCONFIG_DEVICE_INFO_GET_SOURCE_NAME , usually something like \\.\DISPLAY1, \\.\DISPLAY2, etc.

Once you have that device name, you can use the EnumDisplaySettingsW function to enumerate all DEVMODE for this device, this will give you all possible combination of modes (resolution, frequency, etc.) that the device supports (that can easily return hundreds of modes).

Once you have that you just need to group them by DEVMODE's dmDisplayFrequency field (and sort it).

  • Related