環境:
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
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/116.html
標籤:WinForm
