你可以使用C#或C++来获取默认/推荐的监视器设备模式吗?

huangapple go评论85阅读模式
英文:

How can I get the default/recommend monitor device mode in C# or C++?

问题

我可以使用EnumDisplaySettingsA来获取所有监视器模式(DEVMODEA),例如在此C#代码片段中:

public static extern int EnumDisplaySettingsA(string lpszDeviceName, int iModeNum, ref DEVMODEA lpDevMode);

但如何获取默认和/或推荐的模式,就像设置中的一样?

我还想知道,如果监视器当前处于禁用状态,并且我没有关于要启用哪种模式的信息,是否有默认模式可以获取。因此,确保一种分辨率绝对可用。

PS:我知道这个超过10年的问题没有回答,但情况可能已经发生变化:https://stackoverflow.com/q/8390344/356726

英文:

I can get all monitor modes (DEVMODEA) by EnumDisplaySettingsA, e.g. as in this C# snippet:

public static extern int EnumDisplaySettingsA(string lpszDeviceName, int iModeNum, ref DEVMODEA lpDevMode);

But how can I get the default and/or recommended mode as in the settings?

你可以使用C#或C++来获取默认/推荐的监视器设备模式吗?

I also wonder if there is a default mode I can retrieve if the monitor is currently DISABLED and I have no information on which mode to enable. So one mode (resolution) which is definitely working.

PS: I am aware of this >10 years old question with no response, but things might have changed: https://stackoverflow.com/q/8390344/356726

答案1

得分: 1

根据CCD Summaries and Scenarios,显示控制面板小程序使用这些功能

就推荐模式而言,使用DisplayConfigGetDeviceInfoDISPLAYCONFIG_DEVICE_INFO_GET_TARGET_PREFERRED_MODE

查看QueryDisplayConfig,了解DisplayConfigGetDeviceInfo的示例。

英文:

According to CCD Summaries and Scenarios, The display control panel applet uses such functions.

As far as the recommended mode is concerned, use DisplayConfigGetDeviceInfo with DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_PREFERRED_MODE.

See QueryDisplayConfig for an example of DisplayConfigGetDeviceInfo.

huangapple
  • 本文由 发表于 2023年7月31日 22:20:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/76804519.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定