es programa para cambiar la resolución de la pantalla
clase
_____________________
Imports System.Runtime.InteropServices
Public Class pantalla
Public Const DISP_CHANGE_SUCCESFUL As Integer = 0
Public Const ENUM_CURRENT_SETTINGS As Integer = -1
Public Const ENUM_REGISTRY_SETTINGS As Integer = -2
Public Const CCHDEVICENAME As Integer = 32
Public Const CCHFORNAME As Integer = 32
Public Const DM_BITSPERPEL As Integer = 40000
Public Const DM_PELSDWITH As Integer = 80000
Public Const DM_PELSHEIGHT As Integer = 100000
<StructLayout(LayoutKind.Secuential)>
Public Structure DEVMODE
Public dmdevidename As String
Public dmspecversion As Integer
Public dmdriverversion As Integer
Public dmsize As Integer
Public dmDriveBeta As Integer
Public dmdrivextra As Integer
Public dmfields As Long
Public dmDisplayOrientation As ScreenOrientation
Public dmorientation As Integer
Public dmpapersize As Integer
Public dmpaperlength As Integer
Public dmpaperwidth As Integer
Public dmscale As Integer
Public dmcopies As Integer
Public dmdefaultsource As Integer
Public dmprintquality As Integer
Public dmcolor As Integer
Public dmduplex As Integer
Public dmresolution As Integer
Public dmttoption As Integer
Public dmcollate As Integer
Public dmFormName As String
Public dmunusedpadding As Integer
Public dmbitsperpel As Long
Public dmpelswidth As Long
Public dmpelsheight As Long
Public dmdisplayflags As Long
Public dmdisplayfrequency As Long
End Structure
<DllImport("-user32.dll", charset:=charset.Auto > _
Public Shared Function EnumDislaySettings(ByVal lpszdevicename As Long, _
ByVal imodem As Integer, ByRef ipdevmode As DEVMODE) As Boolean
End Function
End Class
______________________________
from
Public Class Form1
Public resCambio As Boolean
Public resAlto As Integer
Public resAncho As Integer
Public resBits As Integer
Public Structure tRes
Private Alto As Integer
Private Ancho As Integer
Private Bts As Integer
End Structure
pantalla DEVMODE Devmod = new pantalla.DEVMODE();
tResol[]resDisponibles = new tResol [0];
resDisponible (0) As tresol
Int nuevaRes;
Public Structure
void Resolucion()
int i;
bool hay resoluciones;
DevMode.dmSize=(short)MArshall.SizeOf(DevMode);
i=0;
do
hayResolucion = pantalla.EnumDisplaySettings(null,i,DevMode);
i+=1;
if(hayResolucion)
sting s =DevMode.dMPelsWidth.Tostring() + "x" +
DevMode.dmPelsHeight.tostring() + "x" +
DevMode.dmBitsPerpel.tostring() + "Bits";
Ist Resoluciones.Items.Add(&);
array:Resize(resDisponibles, 1);
resDisponibles(i-1).Ancho=DevMode.dmWidth;
resDisponibles(i-1).Alto=DevMode.dmHeight;
resDisponibles(i-1).Bits=DevMode.mdBitsPerpel;
while(hay Resolucion);
End Structure
Sub CambiarRes(ByVal Ancho As Integer, ByVal Alto As Integer, ByVal Bits As Integer)
Dim noCambio As Integer
DevMod.dmSize = CType(Marshal.SizeOf(DevMod), Short)
DevMod.dmFields = pantalla.DM_PELSDWITH Or pantalla.DM_PELSHEIGHT Or pantalla.DM_BITSPERPEL
DevMod.dmPELSDWITH = Ancho
DevMod.dmPELSHEIGHT = Alto
DevMod.dmBITSPERPEL = Bits
If (noCambio = pantalla.ChangeDisplaySettings(DevMod, 0) <> pantalla.DISP_CHANGE_SUCCESFUL) Then MessageBox.Show("Error: " & noCambio.ToString() & "al cambiar la resolucion de pantalla", "Error") Else
resCambio = True
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
CambiarRes(resDisponibles [nuevaRes].Ancho, resDisponibles [nuevaRes].Alto, resDisponibles [nuevaRes].Bits)
nuevaRes = istResolucion.Selected Index
txtNueva.Text = resDisponibles(nuevaRes).Ancho.Tostring() & " x " &_
resDisponibles(nuevaRes).Alto.Tostring() & " " &_
resDisponibles(nuevaRes).Bits.Tostring() & " Bits "
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
End Sub
Private Sub chkRestaurar_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkRestaurar.CheckedChanged
If chkRestaurar.Checked And resCambio Then
CambiarRes(resAncho, resAlto, resBits)
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
CambiarRes(resAncho, resAlto, resBits)
resCambio = False
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
resCambio = False
DevMod.dmSize = Ctype (Marshal.SizeOf(DevMod,short )
pantalla.EnumDisplaySettings(Nothing, ENUM_CURRENT_SETTINGS, DevMode)
resAncho = DevMod.dmWidth
resAlto = DevMod.dmHeight
resBits = DevMod.dmBitsPerPel
txtResolucion.Text = resAncho.ToString() & " x " & resAlto.ToString() & " " & resBits.ToString() & "Bits"
resoluciones()
End Sub
End Class