QQ宠物的VC程序(IECustom.rar)
大家都知道,QQ宠物启动时,程序进程中会出现MagicFlash.exe,其实MagicFlash.exe就是一个网页查看程序,程序把当前屏幕的固定区域截取下來,做这网页的背景,然后插入一个ActiveX小插件(当然是FLASH了),用来播放你给的Flash,同时把Flash的背景设为透明。
CString str;
str = " \
<html>\r\n \
<head>\r\n \
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\" />\r\n \
</head>\r\n \
<body scroll=\"no\" background=\"image.bmp\" leftmargin=\"0\" topmargin=\"0\" style=\"width: 100%; border-width=0; border-style:none\">\n<SCRIPT LANGUAGE=\"JavaScript\">\r\n \
function ID1_DoFSCommand(command, args)\n \
{\r\n \
if(command==\"window\" &&args==\"closeResult close\")\r\n \
{\r\n \
document.getElementById(\"V1\").innerHTML = \"\";\r\n \
}\r\n \
}\r\n \
</SCRIPT>\r\n \
<SCRIPT LANGUAGE=\"VBScript\">\r\n \
On Error Resume Next\r\n \
Sub ID1_FSCommand(ByVal command, ByVal args)\r\n \
Call ID1_DoFSCommand(command, args)\r\n \
End Sub\r\n \
</SCRIPT>\r\n \
<DIV ID=\"V1\">\r\n \
<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" id=\"ID1\" width=\"200\" height=\"200\" align=\"middle\">\r\n \
<param name=\"movie\" value=\"1111100301.swf\" />\r\n \
<param name=\"quality\" value=\"high\" />\r\n \
<param name=\"wmode\" value=\"TRANSPARENT\" />\r\n \
<param name=\"bgcolor\" value=\"#ffffff\" />\r\n \
<param name=\"allowScriptAccess\" value=\"sameDomain\" />\r\n \
<param name=\"scale\" value=\"showall\" />\r\n \
</object>\r\n \
</DIV>\r\n \
</body>\r\n \
</html>";
截屏:
void CopyScreenToBitmapEx(LPRECT lpRect)
{
CDC *pDC;//屏幕DC
pDC = CDC::FromHandle(::GetDC(NULL));//获取当前整个屏幕DC
int BitPERPixel = pDC->GetDeviceCaps(BITSPIXEL);//获得颜色模式
int nX, nY, nX2, nY2;
// 选定区域坐标
int nWidth, nHeight;
nX = lpRect->left;
nY = lpRect->top;
nX2 = lpRect->right;
nY2 = lpRect->bottom;
//确保选定区域是可见的
if (nX <0)
nX = 0;
if (nY <0)
nY = 0;
if (nX2 >m_xScreen)
nX2 = m_xScreen;
if (nY2 >m_yScreen)
nY2 = m_yScreen;
nWidth = nX2 - nX;
nHeight = nY2 - nY;
CDC memDC;//内存DC
memDC.CreateCompatibleDC(pDC);
CBitmap memBitmap, *oldmemBitmap;//建立和屏幕兼容的bitmap
memBitmap.CreateCompatibleBitmap(pDC, nWidth, nHeight);
oldmemBitmap = memDC.SelectObject(&memBitmap);//将memBitmap选入内存DC
memDC.BitBlt(0, 0, nWidth, nHeight, pDC, nX, nY, SRCCOPY);//复制屏幕图像到内存DC
//以下代码保存memDC中的位图到文件
BITMAP bmp;
memBitmap.GetBitmap(&bmp);//获得位图信息
CString strPath;
GetModuleFileName(NULL,strPath.GetBuffer(MAX_PATH),MAX_PATH);
strPath.ReleaseBuffer(MAX_PATH);
strPath = strPath.Left(strPath.ReverseFind('\\') + 1) + "image.bmp";
FILE *fp = fopen(strPath, "w+b");
BITMAPINFOHEADER bih = {0};//位图信息头
bih.biBitCount = bmp.bmBitsPixel;//每个像素字节大小
bih.biCompression = BI_RGB;
bih.biHeight = bmp.bmHeight;//高度
bih.biPlanes = 1;
bih.biSize = sizeof(BITMAPINFOHEADER);
bih.biSizeImage = bmp.bmWidthBytes * bmp.bmHeight;//图像数据大小
bih.biWidth = bmp.bmWidth;//宽度
BITMAPFILEHEADER bfh = {0};//位图文件头
bfh.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);//到位图数据的偏移量
bfh.bfSize = bfh.bfOffBits + bmp.bmWidthBytes * bmp.bmHeight;//文件总的大小
bfh.bfType = (WORD)0x4d42;
fwrite(&bfh, 1, sizeof(BITMAPFILEHEADER), fp);//写入位图文件头
fwrite(&bih, 1, sizeof(BITMAPINFOHEADER), fp);//写入位图信息头
byte * p = new byte[bmp.bmWidthBytes * bmp.bmHeight];//申请内存保存位图数据
GetDIBits(memDC.m_hDC, (HBITMAP) memBitmap.m_hObject, 0, nHeight, p,
(LPBITMAPINFO) &bih, DIB_RGB_COLORS);//获取位图数据
fwrite(p, 1, bmp.bmWidthBytes * bmp.bmHeight, fp);//写入位图数据
delete [] p;
fclose(fp);
memDC.SelectObject(oldmemBitmap);
}
需要程序的请留个言。