tags:

views:

90

answers:

1

how to read screen resolution - and change this resolution ?

ex: i read 800X600 and i want to change to 1024X768

in WinForm - C#

+2  A: 

First of all: Which screen? You know that there can be multiple ones.

From Windows Forms you can use the Screen class to retrieve the dimensions of a specific screen. You can use the ChangeDisplaySettingsEx API function to change the resolution of a display. I don't think there is a purely managed way to do it.

Joey
For setting the resolution, invoke that API function with P/Invoke (see the `DllImport` attribute). The device name required for this can be got via the `System.Windows.Forms.Screen.DeviceName` property. -- You might also be able to *temporarily* change screen resolution via DirectDraw; see `Microsoft.DirectX.DirectDraw` (though the documentation says this namespace has become obsolete).
stakx