VC SDK 全屏截图代码

来源:互联网 发布:软件测试工程师培训班 编辑:程序博客网 时间:2024/05/20 02:53
#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);//ImageFormatJPEGreturn 0;}

原创粉丝点击