转载自http://blog.csdn.net/lijgame/article/details/1447921
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Imaging;
namespace first
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//获得当前屏幕的分辨率
Screen scr = Screen.PrimaryScreen;
Rectangle rc = scr.Bounds;
int iWidth = rc.Width;
int iHeight = rc.Height;
//创建一个和屏幕一样大的Bitmap
Image myImage = new Bitmap(iWidth, iHeight);
//从一个继承自Image类的对象中创建Graphics对象
Graphics g = Graphics.FromImage(myImage);
//抓屏并拷贝到myimage里
g.CopyFromScreen(new Point(0, 0), new Point(0, 0), new Size(iWidth, iHeight));
//保存为文件
myImage.Save("1.jpg");
}
}
}