windows 高效获取windows桌面截图

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5292700/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 16:25:59  来源:igfitidea点击:

efficiently acquiring a screenshot of the windows desktop

c++windowsperformancebitmapgdi

提问by

Is there a more efficient way of getting a copy of the windows desktop ( using GDI or any other library ) than the code below

有没有比下面的代码更有效的方式来获取 Windows 桌面的副本(使用 GDI 或任何其他库)

HDC      dcDesktop;
HDC         dcMem;
HBITMAP     hbmpMem;
HBITMAP     hOriginal;
BITMAP      bmpDesktopCopy;

dcDesktop   = GetDC( GetDesktopWindow() ); 
dcMem       = CreateCompatibleDC( dcDesktop );
hbmpMem     = CreateCompatibleBitmap( dcMem, m_lWidth, m_lHeight );

BitBlt( dcMem, 0, 0, m_lWidth, m_lHeight, dcDesktop, 0, 0, SRCCOPY );

// Copy the hbmpMem to the desktop copy
GetObject(hbmpMem, sizeof(BITMAP), (LPSTR)&bmpDesktopCopy);

采纳答案by Addi

http://www.codeproject.com/KB/dialog/screencap.aspx

http://www.codeproject.com/KB/dialog/screencap.aspx

This page has a couple different ways to take screenshots. The DirectX method they use seems simple enough.

此页面有几种不同的截屏方式。他们使用的 DirectX 方法似乎很简单。

Aside from what's mentioned in that article, I don't think there's any more an efficient method of capturing the desktop.

除了那篇文章中提到的内容之外,我认为没有任何更有效的方法来捕获桌面。