VC SDK 全屏截图代码

#include <windows.h>
#include <atlimage.h>

int main()
{
	HDC hdcSrc = GetDC(NULL);
	int nBitPerPixel = GetDeviceCaps(hdcSrc, BITSPIXEL);
	int nWidth = GetDeviceCaps(hdcSrc, HORZRES);
	int nHeight = GetDeviceCaps(hdcSrc, VERTRES);
	CImage image;
	image.Create(nWidth, nHeight, nBitPerPixel);
	BitBlt(image.GetDC(), 0, 0, nWidth, nHeight, hdcSrc, 0, 0, SRCCOPY);
	ReleaseDC(NULL, hdcSrc);
	image.ReleaseDC();
	image.Save(L"M:\\1.png", Gdiplus::ImageFormatPNG);//ImageFormatJPEG
	return 0;
}

猜你喜欢

转载自blog.csdn.net/cyousui/article/details/11990225
vc