周年更新 BitBlt 截图问题
先上代码
IntPtr hdcSrc = IntPtr.Zero;
hdcSrc = User32.GetWindowDC(handle);
// create a device context we can copy to
IntPtr hdcDest = GDI32.CreateCompatibleDC(hdcSrc);
// create a bitmap we can copy it to,
// using GetDeviceCaps to get the width/height
IntPtr hBitmap = GDI32.CreateCompatibleBitmap(hdcSrc, width, height);
// select the bitmap object
IntPtr hOld = GDI32.SelectObject(hdcDest, hBitmap);
// bitblt over
GDI32.BitBlt(hdcDest, 0, 0, width, height, hdcSrc, x, y, GDI32.SRCCOPY);
// restore selection
GDI32.SelectObject(hdcDest, hOld);
// clean up
GDI32.DeleteDC(hdcDest);
User32.ReleaseDC(handle, hdcSrc);
// get a .NET image object for it
Image img = Image.FromHbitmap(hBitmap);
// free up the Bitmap object
GDI32.DeleteObject(hBitmap);
((Bitmap)img).Save("1.bmp");
return (Bitmap)img;
问题描述,此段代码是截取指定DirextX窗口图片,自从更新了Win10 周年更新后无法工作,截取出来是黑的,之前都是好好的
但是如果把handle设置为GetDesktopWindow() ,可以截图 包括DirextX窗口内容,如何修改才能截取指定DirextX窗口图片
参考文档
https://support.microsoft.com/en-us/kb/210108