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

有没有办法以编程方式更改屏幕分辨率或在Windows XP中启用/禁用多个显示器? 例如,从一台显示器的1024×768变为两台显示器的1280×104? 我会最感兴趣的是一个win32函数来做到这一点,但任何可以绑定到Windows快捷方式就足够了。

你可以使用EnumDisplayDevices来找出你有什么可用的显示和EnumDisplaySettings来获得你的显示器的可用分辨率列表。 使用ChangeDisplaySettings来设置你需要的分辨率。

是的,但不是.NET的一部分。 您将需要使用,调用或编写包装来访问Win32 API。

请参阅ChangeDisplaySettings及相关功能。

在这里你可以找到一个基本的例子。

您可以使用http://www.autohotkey.com轻松编写脚本

这里有一个脚本,用于在一台显示器和两台显示器之间切换Windows + 1和Windows + 2

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. #Warn ; Recommended for catching common errors. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. #1:: Send {LWin} WinWaitActive Start menu Send Adjust Screen Resolution Send {enter} WinWaitActive Screen Resolution ControlClick ComboBox3 Send {PgDn} Send {Up} ; Select "Show desktop only on 1" Send {enter} Sleep 3000 ; workaround - cannot select accept/revert window? Send {left} Send {enter} ; accept changes Return #2:: Send {LWin} WinWaitActive Start menu Send Adjust Screen Resolution Send {enter} WinWaitActive Screen Resolution ControlClick ComboBox3 Send {PgDn} Send {Up} Send {Up} ; Select "Extend these displays" Send {enter} Sleep 3000 ; workaround - cannot select accept/revert window? Send {left} Send {enter} ; accept changes Return 

阅读给定的链接,很容易。

只需下载该DLL的好去..

MyTactics.blogspot.in

 Screen Srn=Screen.PrimaryScreen; int tempWidth=Srn.Bounds.Width; int tempHeight=Srn.Bounds.Height; Console.WriteLine("Current Screen width is {0} and height is {1}.", tempWidth, tempHeight);