C#怎么获取屏幕分辨率

我是新手,请给我一段源代码,最好写下注释,谢谢
2024-12-26 01:59:57
推荐回答(3个)
回答1:

Rectangle rect = new Rectangle();
rect = Screen.GetWorkingArea(this);
rect.Width;//屏幕宽
rect.Height;//屏幕高

回答2:

Console.WriteLine("高度"+Screen.PrimaryScreen.WorkingArea.Height+"宽度"+Screen.PrimaryScreen.WorkingArea.Width);

回答3:

System.Drawing.Rectangle rect =
System.Windows.Forms.Screen.PrimaryScreen.Bounds;

int h = rect.Height; //高(像素)
int w = rect.Width; //宽(像素)