WinForm版 屏幕截图

环境:

Vs 2015

.net 4.5.2

源码:

public static void toScreen()        {            ThreadStart ts = new ThreadStart(() =>//开线程              {                  Screen scr = Screen.PrimaryScreen;                  Rectangle rc = scr.Bounds;                  int iWidth = rc.Width;                  int iHeight = rc.Height;                  Image myImage = new Bitmap(iWidth, iHeight);                  Graphics gs = Graphics.FromImage(myImage);                  gs.CopyFromScreen(new Point(0, 0), new Point(0, 0), new Size(iWidth, iHeight));                  string sFilesName = DateTime.Now.ToString("yyyyMMddHHmmss");//文件名                  string sPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);//获取桌面路径                  myImage.Save($@"{sPath}\{sFilesName}.bmp");              });            Thread thread = new Thread(ts);            thread.Start();        }

View Code

(0)

相关推荐