我想编写一个程序,可以动态截取屏幕,不知在VC++该如何实现?
解决方案 »
- vlc 内存错误 懂vlc的进
- cstring replace函数问题
- error C2064: term does not evaluate to a function
- msdn中的虚函数
- 高分请教C++/VC++向https服务器发送请求的问题
- 如何使用IWebBrowser2接口的ExecWB方法打开文件?
- EDIT的问题?
- 求教:应用程序的消息分发循环是否一直在运行?
- 如何设置对话框,按钮,列表框,的背景颜色?
- 您的程序可能将在2038年后全面瘫痪!!!
- 多线程中如何根据handle判断有CSocket对象Attach了?
- 300分问个关于mirror驱动的问题``到底是怎样生成sys文件的啊。。
dc.CreateDC("DISPLAY",NULL,NULL,NULL);
char filename[128];
memset(filename,0,sizeof(filename));
int nX = 0;
int nY = 0;
int Width=GetSystemMetrics(SM_CXSCREEN);
int Height=GetSystemMetrics(SM_CYSCREEN);
CBitmap bm;
bm.CreateCompatibleBitmap(&dc,Width,Height);
CDC tdc;
tdc.CreateCompatibleDC(&dc);
CBitmap *pOld=tdc.SelectObject(&bm);
tdc.BitBlt(0,0,Width,Height,&dc,nX,nY,SRCCOPY);
tdc.SelectObject(pOld);
BITMAP btm;
bm.GetBitmap(&btm);
DWORD size=btm.bmWidthBytes*btm.bmHeight;
LPSTR lpData=(LPSTR)GlobalAlloc(GPTR,size);
BITMAPINFOHEADER bih;
bih.biBitCount=btm.bmBitsPixel;
bih.biClrImportant=0;
bih.biClrUsed=0;
bih.biCompression=0;
bih.biHeight=btm.bmHeight;
bih.biPlanes=1;
bih.biSize=sizeof(BITMAPINFOHEADER);
bih.biSizeImage=size;
bih.biWidth=btm.bmWidth;
bih.biXPelsPerMeter=0;
bih.biYPelsPerMeter=0;
GetDIBits(tdc,bm,0,bih.biHeight,lpData,(BITMAPINFO*)&bih,DIB_RGB_COLORS);
BITMAPFILEHEADER bfh;
bfh.bfReserved1=bfh.bfReserved2=0;
bfh.bfType=((WORD)('M'<< 8)|'B');
bfh.bfSize=54+size;
bfh.bfOffBits=54;
bm.DeleteObject();
tdc.DeleteDC();
dc.DeleteDC();
CFile bf;
if(bf.Open(csFolder,CFile::modeCreate|CFile::modeWrite)){
bf.WriteHuge(&bfh,sizeof(BITMAPFILEHEADER));
bf.WriteHuge(&bih,sizeof(BITMAPINFOHEADER));
bf.WriteHuge(lpData,size);
bf.Close();
}
else
return ;
GlobalFree(lpData);
return ;