2008-10-18 65 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);