-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdllmain.cpp
83 lines (81 loc) · 3.15 KB
/
dllmain.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "pch.h"
#include <windows.h>
const char* ClipBoardData() {
if (OpenClipboard(NULL)) {
HANDLE hClipboardData = GetClipboardData(CF_TEXT);
if (hClipboardData) {
const char* newClipboardData = static_cast<const char*>(GlobalLock(hClipboardData));
if (newClipboardData) {
returnClipBoardData = newClipboardData;
size_t clipboardLength = strlen(returnClipBoardData);
HGLOBAL hNewClipboardData = GlobalAlloc(GMEM_MOVEABLE, clipboardLength + 1);
if (hNewClipboardData) {
char* newClipboardDataCopy = static_cast<char*>(GlobalLock(hNewClipboardData));
if (newClipboardDataCopy) {
memcpy(newClipboardDataCopy, returnClipBoardData, clipboardLength + 1);
GlobalUnlock(hNewClipboardData);
SetClipboardData(CF_TEXT, hNewClipboardData);
}
}
GlobalFree(hNewClipboardData);
}
GlobalUnlock(hClipboardData);
}
CloseClipboard();
}
return returnClipBoardData;
}
//BYTE* GetScreenCapture(int &width, int &height) {
// int screenWidth = GetSystemMetrics(SM_CXSCREEN);
// int screenHeight = GetSystemMetrics(SM_CYSCREEN);
// HDC hdcScreen = GetDC(NULL);
// HDC hdcMem = CreateCompatibleDC(hdcScreen);
// HBITMAP hBitmap = CreateCompatibleBitmap(hdcScreen, screenWidth, screenHeight);
//
// SelectObject(hdcMem, hBitmap);
// BitBlt(hdcMem, 0, 0, screenWidth, screenHeight, hdcScreen, 0, 0, SRCCOPY);
//
// BYTE* lpbitmap = nullptr;
//
// if (GetAsyncKeyState(VK_SNAPSHOT) & 0x8000) {
// BITMAPINFOHEADER bi;
// bi.biSize = sizeof(BITMAPINFOHEADER);
// bi.biWidth = screenWidth;
// bi.biHeight = -screenHeight;
// bi.biPlanes = 1;
// bi.biBitCount = 24;
// bi.biCompression = BI_RGB;
// bi.biSizeImage = 0;
// bi.biXPelsPerMeter = 0;
// bi.biYPelsPerMeter = 0;
// bi.biClrUsed = 0;
// bi.biClrImportant = 0;
//
// DWORD dwBmpSize = ((screenWidth * bi.biBitCount + 31) / 32) * 4 * screenHeight;
// lpbitmap = new BYTE[dwBmpSize];
// GetDIBits(hdcScreen, hBitmap, 0, screenHeight, lpbitmap, (BITMAPINFO*)&bi, DIB_RGB_COLORS);
// width = screenWidth;
// height = screenHeight;
// }else {
// OpenClipboard(NULL);
// EmptyClipboard();
// SetClipboardData(CF_BITMAP, hBitmap);
// CloseClipboard();
//
// HBITMAP hClipboardBitmap = static_cast<HBITMAP>(GetClipboardData(CF_BITMAP));
//
// if (hClipboardBitmap) {
// BITMAP bitmapInfo;
// GetObject(hClipboardBitmap, sizeof(BITMAP), &bitmapInfo);
// lpbitmap = new BYTE[bitmapInfo.bmWidthBytes * bitmapInfo.bmHeight];
// GetBitmapBits(hClipboardBitmap, bitmapInfo.bmWidthBytes * bitmapInfo.bmHeight, lpbitmap);
// width = bitmapInfo.bmWidth;
// height = bitmapInfo.bmHeight;
// }
// }
// DeleteObject(hBitmap);
// DeleteDC(hdcMem);
// ReleaseDC(NULL, hdcScreen);
//
// return lpbitmap;
//}