void CleanupWindowCapture()
        {
            if (hdc != IntPtr.Zero)
            {
                Win32Funcs.ReleaseDC(hwnd, hdc);
                hdc = IntPtr.Zero;
            }

            if (hDest != IntPtr.Zero)
            {
                Win32Funcs.DeleteDC(hDest);
                hDest = IntPtr.Zero;
            }

            if (curRenderingBitmap != IntPtr.Zero)
            {
                Win32Funcs.DeleteObject(curRenderingBitmap);
                curRenderingBitmap = IntPtr.Zero;
            }

            if (cursorHandle != IntPtr.Zero)
            {
                Win32Funcs.DeleteObject(cursorHandle);
                cursorHandle = IntPtr.Zero;
            }
        }
        void FreeWinCapture()
        {
            if (hdc != IntPtr.Zero)
            {
                Win32Funcs.ReleaseDC(hwnd, hdc);
                hdc = IntPtr.Zero;
            }

            if (hDest != IntPtr.Zero)
            {
                Win32Funcs.DeleteDC(hDest);
                hDest = IntPtr.Zero;
            }

            if (curRenderingBitmap != IntPtr.Zero)
            {
                Win32Funcs.DeleteObject(curRenderingBitmap);
                curRenderingBitmap = IntPtr.Zero;
            }
        }