環境: Vs 2015 .net 4.5.2 源碼: public static void toScreen() { ThreadStart ts = new ThreadStart(() =>//開線程 { Screen scr = Screen.PrimaryScreen; Rectangle ...
環境:
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