Rectangle r = this.Bounds;
Image img = new System.Drawing.Bitmap(r.Width, r.Height);
Graphics g = Graphics.FromImage(img);
Point pt = this.PointToScreen(this.Location);
g.CopyFromScreen(pt, new Point(0, 0), r.Size);
string assemblypath = string.Empty;
assemblypath = "E://txt.bmp";
img.Save(assemblypath);
System.Diagnostics.Process.Start(assemblypath);
Rectangle r = this.Bounds;
本文介绍了一段使用 C# 实现屏幕截图的代码。通过创建一个与屏幕相同尺寸的位图对象,并利用 Graphics 类的 CopyFromScreen 方法将屏幕内容复制到位图中,最后保存为图片文件并调用该文件进行预览。

被折叠的 条评论
为什么被折叠?



