Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

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);
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
216 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...