Code:
using System; using System.Drawing; using System.Drawing.Imaging; using System.Windows.Forms; namespace CaptureWindows { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Rectangle rect = Screen.GetBounds(Point.Empty); using (Bitmap bitmap = new Bitmap(rect.Width, rect.Height)) { using (Graphics g = Graphics.FromImage(bitmap)) g.CopyFromScreen(Point.Empty, Point.Empty, rect.Size); bitmap.Save("test.jpg", ImageFormat.Jpeg); } } } }
執行結果: