91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 1KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2021-06-04
  • 語言: C/C++
  • 標簽: C語言??源代碼??

資源簡介

使用C語言寫遠程屏幕監視程序,此處為關鍵代碼,具體參考博文.

資源截圖

代碼片段和文件信息

/*以下代碼為服務器和客戶端連接后的
*其中ImageSock為用來通信的socket
*/
//?Get?the?Screen?DC
HDC?hDC?=?GetDC(?GetDesktopWindow()?);
//?Create?a?compatible?DC
HDC?hCpDC?=?CreateCompatibleDC(?hDC?);
//?Create?a?compatible?bitmap
HBITMAP?hBmp?=?CreateCompatibleBitmap(?hDC?nScreenX?nScreenY?);
//?Select?the?compatible?bitmap?into?the?compatible?DC?and?get?the?old?bitmap?handle
HBITMAP?hOldBmp?=?(HBITMAP)Selectobject(?hCpDC?hBmp?);
//?Copy?the?screen?to?the?compatible?DC
StretchBlt(?hCpDC?0?0?nScreenX?nScreenY?hDC?0?0?nScreenX?nScreenY?SRCCOPY);
//?Fullfill?the?BITMAPINFOHEADER?structure
Getobject(?hBmp?sizeof(BITMAP)?&bmp?);
bi.biSize = sizeof(BITMAPINFOHEADER);
bi.biPlanes = 1;
bi.biWidth = bmp.bmWidth;
bi.biHeight = bmp.bmHeight;
bi.biCompression = BI_RGB;
bi.biSizeImage = bmp.bmHeight?*?bmp.bmWidthBytes;
bi.biBitCount = bmp.bmPlanes?*?bmp.bmBitsPixel;
bi.biXPelsPerMeter =???0;???
bi.biYPelsPerMeter =???0;???
bi.biClrUsed =???0;???
bi.biClrImportant =???0;
//為要傳輸的位圖分配內存,計算所需內存大小
int?nSize?=?sizeof(BITMAPINFOHEADER)?+?bi.biSizeImage;
//?分配內存
char?*lp?=?(char?*)(?new?byte[nSize]?);
//?放位圖的大小,用來通知客戶端
char?Buffer[1024]?=?{0};

while?(1)
{
//??Copy?the?screen?to?the?compatible?DC
StretchBlt(?hCpDC?0?0?nScreenX?nScreenY?hDC?0?0?nScreenX?nScreenY?SRCCOPY);
//?Fullfill?the?BITMAPINFOHEADER?structure
Getobject(?hBmp?sizeof(BITMAP)?&bmp?);
bi.biSize = sizeof(BITMAPINFOHEADER);
bi.biPlanes = 1;
bi.biWidth = bmp.bmWidth;
bi.biHeight = bmp.bmHeight;
bi.biCompression = BI_RGB;
bi.biSizeImage = bmp.bmHeight?*?bmp.bmWidthBytes;
bi.biBitCount = bmp.bmPlanes?*?bmp.bmBitsPixel;
bi.biXPelsPerMeter =???0;???
bi.biYPelsPerMeter =???0;???
bi.biClrUsed =???0;???
bi.biClrImportant =???0;
//復制BITMAPINFOHEADER信息到內存中
memcpy(?lp?&bi?sizeof(BITMAPINFOHEADER)?);

//復制具體的位圖數據到內存中
if?(?ERROR_INVALID_PARAMETER?==?GetDIBits(?hCpDC?hBmp?0?bmp.bmHeight?lp?+?sizeof(BITMAPINFOHEADER)?(LPBITMAPINFO)?&bi?DIB_RGB_COLORS?)?)
{
printf(?“[GetDIBits]?error:ERROR_INVALID_PARAMETER\n“?);
continue;
}

//?Receive?the?feedback
if?(?0?==?recv(?ImageSock?Buffer?1024?0?)?)
break;
if?(?strcmp(?Buffer?“200?OK“?)?)
break;
//?Send?the?screen?data
send(?ImageSock?lp?nSize?0?);
}
ReleaseDC(?GetDesktopWindow()?hDC?);
DeleteDC(?hCpDC?);
delete?[]lp;

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件???????2518??2009-02-14?19:59??CatchScreen.cpp

?????文件????????456??2009-02-14?20:02??Client.cpp

-----------?---------??----------?-----??----

?????????????????2974????????????????????2


評論

共有 條評論