2008-10-18 63 views
17

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

+8

我相信你就别想在做的是,如果没有用户的许可。如果你摆弄我的屏幕分辨率,我会完全生气 - 而且可能不会再使用你的程序。 – 2008-10-19 06:27:44

+0

我完全同意以前的评论。除非这是用于管理幻灯片演示文稿的某种实用工具,否则很难想象应用程序在哪里可以实现这一功能。 – 2008-10-19 06:54:01

回答

2

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

查看ChangeDisplaySettings及相关功能。

Here你可以找到一个基本的例子。

1

你可以很容易的脚本这与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 
-4

阅读给定链路它很容易。

只需下载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);