我正在尝试用C++构建一个键盘记录器.我的键盘记录器的一部分是捕获屏幕.
经过大量的搜索,我决定尝试通过构建一个来了解它是如何工作的.
这是我的屏幕截图代码:
HDC hdc = GetDC(NULL); // get the desktop device context
HDC hDest = CreateCompatibleDC(hdc); // create a device context to use yourself
// get the height and width of the screen
int height = GetSystemMetrics(SM_CYVIRTUALSCREEN);
int width = GetSystemMetrics(SM_CXVIRTUALSCREEN);
// create a bitmap
HBITMAP hbDesktop = CreateCompatibleBitmap(hdc, width, height);
// use the previously created device context with the bitmap
SelectObject(hDest, hbDesktop);
// copy from the desktop device context to the bitmap device context
// call this once …Run Code Online (Sandbox Code Playgroud) c++ ×1