Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        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);
        }