Go to the source code of this file.
◆ _tWinMain()
Definition at line 341 of file screenshot.c.
345{
348
350
352 0,
355 return -1;
356
357 if (bFullScreen)
358 {
360 }
361 else
362 {
364 }
365
367 {
369 0,
370 pScrSht);
371
372 return -1;
373 }
374
376 {
377
379 {
380
382 {
383
385 }
386 }
387 }
388
389
396 0,
400 0,
404 0,
405 pScrSht);
406
407 return 0;
408}
#define HeapFree(x, y, z)
static BOOL DoSaveFile(HWND hwnd, LPTSTR szFileName)
static BOOL ConvertDDBtoDIB(PSCREENSHOT pScrSht)
static BOOL CaptureScreen(PSCREENSHOT pScrSht)
static BOOL DoWriteFile(PSCREENSHOT pScrSht, LPTSTR pstrFileName)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HWND WINAPI GetForegroundWindow(void)
HWND WINAPI GetDesktopWindow(void)
◆ CaptureScreen()
Definition at line 164 of file screenshot.c.
165{
168
169
170
171
172
176
177
180
181
182
187 {
191 }
192
193
195 {
199 }
200
201
204
205
207 0,
208 0,
211 ScreenDC,
212 0,
213 0,
215
216
218
220}
static VOID BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
static VOID GetError(VOID)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
HDC WINAPI GetDC(_In_opt_ HWND)
Referenced by _tWinMain().
◆ ConvertDDBtoDIB()
Definition at line 224 of file screenshot.c.
225{
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
253
257 {
260 }
261
263 if (cClrBits == 1)
264 cClrBits = 1;
265 else if (cClrBits <= 4)
266 cClrBits = 4;
267 else if (cClrBits <= 8)
268 cClrBits = 8;
269 else if (cClrBits <= 16)
270 cClrBits = 16;
271 else if (cClrBits <= 24)
272 cClrBits = 24;
273 else cClrBits = 32;
274
275 if (cClrBits != 24)
276 {
278 0,
280 }
281 else
282 {
284 0,
286 }
287
289 {
292 }
293
299
300 if (cClrBits < 24)
302
306
308
310
311
313 0,
316 {
319 }
320
321
324 0,
329 if (Ret == 0)
330 {
333 }
334
336
337}
BITMAPINFOHEADER bmiHeader
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
int WINAPI GetDIBits(_In_ HDC hdc, _In_ HBITMAP hbm, _In_ UINT start, _In_ UINT cLines, _Out_opt_ LPVOID lpvBits, _At_((LPBITMAPINFOHEADER) lpbmi, _Inout_) LPBITMAPINFO lpbmi, _In_ UINT usage)
struct tagBITMAPINFO * PBITMAPINFO
Referenced by _tWinMain().
◆ DoSaveFile()
Definition at line 137 of file screenshot.c.
138{
140
141 static TCHAR Filter[] =
_T(
"24 bit Bitmap (*.bmp,*.dib)\0*.bmp\0");
142
152
155
158
160}
#define CDERR_GENERALCODES
DWORD WINAPI CommDlgExtendedError(void)
#define OFN_OVERWRITEPROMPT
#define OFN_PATHMUSTEXIST
OPENFILENAMEA OPENFILENAME
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Referenced by _tWinMain().
◆ DoWriteFile()
Definition at line 34 of file screenshot.c.
36{
41
42
45 0,
50
53
54
59 &bmfh,
60 sizeof(bmfh),
61 &dwBytesWritten,
63 if ((!
bSuccess) || (dwBytesWritten <
sizeof(bmfh)))
64 goto fail;
65
66
70 &dwBytesWritten,
73 goto fail;
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
102
103
107 &dwBytesWritten,
109 if ((!
bSuccess) || (dwBytesWritten < pScrSht->lpbi->bmiHeader.biSizeImage))
110 goto fail;
111
112
114
115
118 &bmfh,
119 sizeof(bmfh),
120 &dwBytesWritten,
122 if ((!
bSuccess) || (dwBytesWritten <
sizeof(bmfh)))
123 goto fail;
124
126
127fail:
132
133}
#define INVALID_HANDLE_VALUE
#define FILE_ATTRIBUTE_NORMAL
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Referenced by _tWinMain().
◆ GetError()
Definition at line 10 of file screenshot.c.
11{
13
21 0,
23
25 lpMsgBuf,
28
30}
HLOCAL NTAPI LocalFree(HLOCAL hMem)
DWORD WINAPI GetLastError(void)
#define FORMAT_MESSAGE_IGNORE_INSERTS
#define FORMAT_MESSAGE_FROM_SYSTEM
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Referenced by CaptureScreen(), ConvertDDBtoDIB(), and DoWriteFile().