c#截屏
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
using System.Drawing;
namespace P_Invoke
{
class Program
{
static void Main(string[] args)
{
Bitmap myImage = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);//声明一张图片
Graphics g = Graphics.FromImage(myImage);//封装一个绘图图面
g.CopyFromScreen(new Point(0, 0), new Point(0, 0), new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height));//将屏幕信息拷贝入g中
IntPtr dc1 = g.GetHdc();//获取设备句柄
g.ReleaseHdc(dc1);//释放句柄
myImage.Save(@"d:\jietu.jpg"); //保存图片 }
}
}

浙公网安备 33010602011771号