Click here to Skip to main content
15,887,444 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
HI,
I want to read the current dispaly mode in c#. how do i do that?

thanks,
-shree
Posted
Comments
Sergey Alexandrovich Kryukov 15-May-12 21:59pm    
What are those display modes? Never heard of them? In what application type or UI library?
--SA
sri.v@rediffmail.com 16-May-12 0:45am    
we can use windows API to read this dispaly mode. but i do not know how to read this.

1 solution

With this code you get the screen resolution and the DPI number:
C#
int deskHeight = Screen.PrimaryScreen.Bounds.Height;
int deskWidth = Screen.PrimaryScreen.Bounds.Width;

int currentDPI = 0;
using (Graphics g = this.CreateGraphics())
{
  currentDPI = (int)g.DpiX;
}
MessageBox.Show("Your screen resolution is " + deskWidth + "x" + deskHeight);
MessageBox.Show("Your dpi is " + currentDPI);
 
Share this answer
 
Comments
sri.v@rediffmail.com 16-May-12 0:43am    
hi,
which name space i need to add it in
meens using ?
JF2015 16-May-12 0:54am    
System.Windows.Forms and System.Drawing.Graphics
VJ Reddy 16-May-12 0:58am    
Good answer. 5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900