命名空间:
using System.Drawing;
using System.Drawing.Imaging;
using System.Windows.Forms;
相关代码
//获得当前屏幕的分辨率
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(@"c:/1.jpeg");
本文转自today4king博客园博客,原文链接:http://www.cnblogs.com/jinzhao/archive/2009/10/12/1581752.html,如需转载请自行联系原作者