#include <time.h>
#include <afxwin.h>
#include <stdio.h>
#include <comdef.h>
#include <iostream>
#include <atlimage.h>
/*
* hwnd:要截图的窗口的句柄
* fileName:要比较的图片的路径
* offsets:有4个成员的int型数组,用于设置比较图片时,上、下、左、右的偏移量
* offsets[0]:左
* offsets[1]:上
* offsets[2]:右
* offsets[3]:下
*/
bool print_screen(HWND hwnd, const char* fileName, int offsets[])
{
LPCTSTR pFileName = NULL;
if(sizeof(TCHAR)==sizeof(char))
{
pFileName=(LPCTSTR)fileName;
}
else
{
int length= sizeof(TCHAR)*(strlen(fileName)+1);
LPTSTR tcBuffer=new TCHAR[length];
memset(tcBuffer,0,length);
MultiByteToWideChar(CP_ACP,0,fileName,strlen(fileName),tcBuffer,len
C++截屏当前活动窗口保存成BMP文件以及BMP文件的比较
最新推荐文章于 2023-10-14 23:06:19 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)