周年更新 BitBlt 截图问题

weixin_38049686 2016-08-17 04:22:45
先上代码 
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
...全文
18 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复

476

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧