![](https://i0.wp.com/niteshkejriwal.com/wp-content/uploads/2012/12/dotnet-solutions.png?resize=131%2C134&ssl=1)
How to Get Width & Height of Desktop in WinForms
Friends,
In certain scenarios we need to know the screen resolution our desktop application will be running on. To get this information, Microsoft provides us with a very handy class namely SystemInformation that can be found in System.Windows.Forms namespace. Using this class, we can almost every information about the current system environment, the application is running on.
To get the Height and Width of the Desktop screen, use the below 2 lines of code –
C#
int height = SystemInformation.VirtualScreen.Height; int width = SystemInformation.VirtualScreen.Width;
VB.Net
Dim height as Integer = SystemInformation.VirtualScreen.Height Dim width as Integer = SystemInformation.VirtualScreen.Width
Hope you like this post! Cheers!