Pregunta

¿Hay alguna manera de cambiar mediante programación la resolución de la pantalla o habilitar / deshabilitar varios monitores en Windows XP? Por ejemplo, ¿cambiar de 1024x768 con un monitor a 1280x104 en dos monitores? Estaría más interesado en una función win32 para hacer esto, pero cualquier cosa que pueda estar vinculada a un acceso directo de Windows sería suficiente.

¿Fue útil?

Solución

Puede usar EnumDisplayDevices para averiguar qué pantallas tiene disponibles y EnumDisplaySettings para obtener una lista de las resoluciones disponibles para sus pantallas. Use ChangeDisplaySettings para establecer la resolución que necesita.

Otros consejos

Sí, pero no es parte de .NET. Deberá usar, invocar o escribir un contenedor para acceder a la API de Win32.

Consulte ChangeDisplaySettings y función relacionada.

Aquí puede encontrar un ejemplo básico.

Puede escribir esto fácilmente con http://www.autohotkey.com

Aquí hay un script para cambiar entre un monitor y dos monitores con Windows + 1 y 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

Leer el enlace dado es fácil.

acaba de descargar el dll el bueno para ir ..

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);
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top