Tell me, is it possible with C # or WinApi to get information about the physical dimensions of the screen: diagonal or width and height?

  • Please, unsubscribe from whom the results coincided with the line F-) I'm lying godlessly. - karmadro4

4 answers 4

Using only .NET there is no possibility to get physical dimensions. The Windows API has a function GetDeviceCaps, called with the parameters HORZSIZE and VERTSIZE, it can give the required values.

    Using .Net System.Windows.Forms.SystemInformation.PrimaryMonitorSize;

      using (Graphics g = CreateGraphics()) { int W = (int)(Screen.PrimaryScreen.Bounds.Width / g.DpiX * 2.54) int H = (int)(Screen.PrimaryScreen.Bounds.Height / g.DpiY * 2.54) } 

      it seems to work like that

        In C #, I don’t know, but in Visual Basic 6 you can:

        Private Sub cmdScreen_Click () Print Screen.Height / 15 & "height" Print Screen.Width / 15 & "width" End Sub