简体   繁体   English

如何更改桌面屏幕分辨率

[英]how to change desktop screen resolution

我想在桌面应用程序中使用C#代码更改屏幕分辨率。

This is a similar question to "I want to change the clock" or "I want to change the user password" or "I want to change the Windows theme". 这与“我想改变时钟”或“我想改变用户密码”或“我想改变Windows主题”类似。 An application program has no business making such system configuration changes, accordingly it isn't wrapped by the .NET framework. 应用程序无需进行此类系统配置更改,因此,.NET框架不会对其进行包装。

You can do it, but it will require P/Invoke. 您可以执行此操作,但需要P / Invoke。 Use ChangeDisplaySettingsEx() . 使用ChangeDisplaySettingsEx() Not exactly easy to use, nor very safe to use. 并非完全易于使用,也不十分安全。 Lots of LCD panels only look good in one particular resolution, the one that the user selected. 许多LCD面板仅在一种特定的分辨率(用户选择的一种)上看起来不错。 Picking a resolution that the monitor cannot support produces a black screen and the three-finger salute. 选择显示器无法支持的分辨率会产生黑屏,并会向三指致敬。 Smoke in the good old days. 在过去的好日子里吸烟。

You can't do it by build in classes in C#/.net, but you can do it by win api, it is explained here . 您无法通过在C#/。net中的类中进行构建来实现,但是可以通过win api来实现,这在此处进行了说明。 Then go to pinvoke.net or create your p/invoke methods manually. 然后转到pinvoke.net或手动创建p / invoke方法。

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

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