bool CaptureScreenPng(CRect dst, CString Path)
{
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);
CRect rect;
rect.left = 0;
rect.right = (dst.right - dst.left);
rect.top = 0;
rect.bottom = (dst.bottom - dst.top);
//修改图片大小
CImage image1;
image1.Create(rect.right, rect.bottom, nBitPerPixel);
image.StretchBlt(image1.GetDC(), rect, dst);
::ReleaseDC(NULL, hdcSrc);
image.ReleaseDC();
image1.ReleaseDC();
image1.Save(Path, Gdiplus::ImageFormatPNG);//ImageFormatJPEG
image1.Destroy();
return true;
}