获取屏幕信息
范例说明:
本范例是通过读取C#的Screen对象相关属性,获取屏幕信息,程序运行效果如图:
程序代码:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace Demo1_5 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { this.lblDesktopWidth.Text = "桌面宽:" + Screen.PrimaryScreen.WorkingArea.Width; this.lblDesktopHeight.Text = "桌面高:" + Screen.PrimaryScreen.WorkingArea.Height; this.lblScreenWidth.Text = "屏幕宽:" + Screen.PrimaryScreen.Bounds.Width; this.lblScreenHeight.Text = "屏幕高:" + Screen.PrimaryScreen.Bounds.Height; } } }