获取屏幕信息

范例说明:

本范例是通过读取C#的Screen对象相关属性,获取屏幕信息,程序运行效果如图:

image 

程序代码:

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;
        }
    }
}
posted @ 2010-08-30 22:27  黑色草莓  阅读(279)  评论(0编辑  收藏  举报