public static Bitmap CaptureApplicationScreenshot(int pId) { var proc = Process.GetProcessById(pId); var hWnd = proc.MainWindowHandle; var window = new ProcessWindow(proc); window.Focus(); Rect rc; GetWindowRect(hWnd, out rc); Bitmap bmp = new Bitmap(rc.Width, rc.Height, PixelFormat.Format32bppArgb); Graphics gfxBmp = Graphics.FromImage(bmp); IntPtr hdcBitmap = gfxBmp.GetHdc(); PrintWindow(hWnd, hdcBitmap, 0); gfxBmp.ReleaseHdc(hdcBitmap); gfxBmp.Dispose(); return bmp; }
public static Bitmap CaptureApplicationScreenshot(int pId) { var proc = Process.GetProcessById(pId); var hWnd = proc.MainWindowHandle; var window = new ProcessWindow(proc); window.Focus(); Rect rc; GetWindowRect(hWnd, out rc); Bitmap bmp = new Bitmap(rc.Width, rc.Height, PixelFormat.Format32bppArgb); Graphics gfxBmp = Graphics.FromImage(bmp); IntPtr hdcBitmap = gfxBmp.GetHdc(); PrintWindow(hWnd, hdcBitmap, 0); gfxBmp.ReleaseHdc(hdcBitmap); gfxBmp.Dispose(); return(bmp); }