windows 任何 Win32 API 来获取屏幕截图?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2606899/
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 14:15:05  来源:igfitidea点击:

Any Win32 APIs to get the screenshots?

winapivisual-c++screenshotwindows

提问by Microkernel

I am writing an app, which needs to take the screen shots automatically (just like pressing PrintScreen button). So please suggest me how to get this done. A raw 24 bit BMP image would suffice.

我正在编写一个应用程序,它需要自动拍摄屏幕截图(就像按下 PrintScreen 按钮一样)。所以请建议我如何完成这项工作。一个原始的 24 位 BMP 图像就足够了。

PLEASE NOTE: My app is in C, so any win32 APIs that can be called from my code is what I am looking for.

请注意:我的应用程序是用 C 语言编写的,因此可以从我的代码中调用的任何 win32 API 都是我正在寻找的。

(Sometimes back I had got an example code from codeproject which used to get the screen shots but the mouse pointer user to blink when the screen shot is taken. As multiple shots are taken this looks irritating to the user, so I don't want the mouse pointer to blink!)

(有时我从 codeproject 中得到了一个示例代码,它用于获取屏幕截图,但是在拍摄屏幕截图时鼠标指针用户会闪烁。因为拍摄了多个镜头,这对用户来说看起来很烦人,所以我不想鼠标指针闪烁!)

回答by Anders

GetDC(NULL)+ BitBlt()

GetDC(NULL)+ BitBlt()

To capture translucent/alpha/layered windows, you must pass the CAPTUREBLTflag to BitBlt, if you do that, the cursor blinks, read this technet articleto find out why.

要捕获半透明/alpha/分层窗口,您必须将CAPTUREBLT标志传递给BitBlt,如果这样做,光标会闪烁,请阅读此技术网文章以找出原因。

On NT6+, you might be able to use the Magnification APIto do what you want.

在 NT6+ 上,您或许可以使用Magnification API来做您想做的事。