Here is how to do it in
System.Windows.Forms
. As you don't have to actually create any form or application with this code, you can also use it in WPF.
Use
System.Windows.Forms.Screen.AllScreens
to get all your screens of the same type
System.Windows.Forms.Screen
. If you need only you primary screen, get just
System.Windows.Forms.Screen.PrimaryScreen
. Look at the properties of each screen. In particular, you can use
System.Windows.Forms.Screen.WorkingArea
and
System.Windows.Forms.Screen.Bounds
.
See
http://msdn.microsoft.com/en-us/library/system.windows.forms.screen.aspx[
^].
Oops!
How to set screen resolution?!!
No, you cannot. Come on, you cannot have such requirement. Just the opposite, you have to write resolution-independent software. If you have requirements for the sizes of the windows, you can develop the UI the way it looks on the higher-resolution screen exactly as the same application on the base minimally required resolution. That's why you don't need to set resolution but only get it.
(I hope you understand that you cannot set resolution higher that it is physically possible no matter how strongly it is required :-).)
—SA