简体   繁体   English

获取已连接显示器的最大可能显示速率

[英]Getting the max possible display rate of connected monitors

I am trying to get programmatically the maximum display rate that Windows allows (ie, Display settings > Advanced display settings > Refresh rate > max value).我试图以编程方式获得 Windows 允许的最大显示速率(即,显示设置 > 高级显示设置 > 刷新率 > 最大值)。 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_INFO s and by using DisplayConfigGetDeviceInfo .我已经使用CCD API通过获取DISPLAYCONFIG_PATH_INFO和使用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.基于 CCD API 的解决方案将是完美的,但替代方案也很好 - 这只是意味着我必须以某种方式协调通过 CCD API 获得的信息与从其他 API 获得的信息。

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.此外,我正在尝试在不使用特定图形后端库(例如 DX12)或游戏制作框架的普通 Windows 可执行文件的上下文中执行此操作。

Thanks !谢谢 !

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.使用 CCD API,您可以使用DisplayConfigGetDeviceInfo使用DISPLAYCONFIG_DEVICE_INFO_TYPE::DISPLAYCONFIG_DEVICE_INFO_GET_SOURCE_NAME获取 GDI 设备名称,通常类似于\\.\DISPLAY1\\.\DISPLAY2等。

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).获得该设备名称后,您可以使用EnumDisplaySettingsW function枚举该设备的所有DEVMODE ,这将为您提供该设备支持的所有可能的模式组合(分辨率、频率等)(可以轻松返回数百种模式).

Once you have that you just need to group them by DEVMODE's dmDisplayFrequency field (and sort it).一旦你有了它,你只需要按 DEVMODE 的dmDisplayFrequency字段对它们进行分组(并对其进行排序)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM