C#: Get complete desktop size?

前端 未结 9 2094
梦谈多话
梦谈多话 2020-11-27 16:40

How do I find out the size of the entire desktop? Not the \"working area\" and not the \"screen resolution\", both of which refer to only o

9条回答
  •  渐次进展
    2020-11-27 16:50

    You can use the Bounds of System.Drawing.

    You can create a function like this

    public System.Windows.Form.Screen[] GetScreens(){
        Screen[] screens = Screen.AllScreens;
        return screens;
    }
    

    and than you can get the screen one, two, etc. in a variable like this:

    System.Windows.Form.Screen[] screens = func.GetScreens();
    System.Windows.Form.Screen screen1 = screens[0];
    

    then you can get the bounds of the screen:

    System.Drawing.Rectangle screen1Bounds = screen1.Bounds;
    

    With this code you will get all the properties like Width, Height, etc.

提交回复
热议问题