Monthly Archives: September 2016

Get Monitor Size programmatically

Hello everyone,

today I want to show you how you can use C# to get the physical size of a monitor in inches. This can be helpful if you need to know the physical size of a monitor and you do not know where it is located or if you want to get a list of average monitor sizes in your company.

All you need to do to make this work is the below code snippet:

using System;
using System.Management;

namespace GetScreenSize
    class Program
        static void Main(string[] args)
            //Get monitor data
            ManagementObjectSearcher searcher = new ManagementObjectSearcher(@"\root\wmi", @"SELECT * FROM WmiMonitorBasicDisplayParams");

            //Calculate and output size for each monitor
            foreach (ManagementObject managementObject in searcher.Get())
                //Calculate monitor size
                double width = (byte)managementObject["MaxHorizontalImageSize"] / 2.54;
                double height = (byte)managementObject["MaxVerticalImageSize"] / 2.54;
                double diagonal = Math.Sqrt(width * width + height * height);

                //Output monitor size
                Console.WriteLine("Monitor Size: {0:F1}\"", diagonal);


If you have multiple monitors connected to your computer the above code will output the size of each monitor.

Important: You need to add a reference to System.Management to make the above code work.

Well, that´s it. Now you are able to get the physical size of your monitor without having to measure it.
I hope you liked my post and I hope to see you again next time 🙂

As always you can download my code from here.


Tagged ,