以编程方式更改屏幕分辨率

changing screen resolution programmatically

IDE: VS2010, c#.net 4.0, winforms

我的应用程序基于 1366x768 屏幕分辨率构建。我有另一个三星液晶显示器,它具有最高分辨率 -> 1920x1080,但在选项列表中(右键单击桌面 -> 屏幕分辨率)它没有 1366x768 分辨率,那么有什么方法可以强制此液晶显示器显示为 1366x768 分辨率,以便我的应用程序可以适应该液晶显示器,操作系统是 Windows 7.

使用nircmd

可以做很多事情
nircmd.exe setdisplay 1366 768 32

它也不是以编程方式,但您可以 start a Process 并调用此实用程序。

强制用户更改分辨率不是一个好的做法。尝试调整您的设计以适应 support different resolution.

此外,您不能强制显示器将其分辨率更改为它不支持的分辨率。

正如 Ferruccio in another question 指出的那样:

You can use EnumDisplayDevices to figure out what displays you have available and EnumDisplaySettings to get a list of available resolutions for your displays. Use ChangeDisplaySettings to set the resolution you need.