Grabby: Write the screenshot to %TEMP%
Means I don't have to ignore *.bmp in the repo. I'll probably make this user-configurable, once we have a configuration system in place. git-svn-id: svn://vcs.sdm.2ki.xyz/Grabby/trunk@14 27729192-006e-004d-b9b5-06fbd0ef7001
This commit is contained in:
		
							parent
							
								
									dc07b5e612
								
							
						
					
					
						commit
						94989c680a
					
				
					 2 changed files with 28 additions and 2 deletions
				
			
		
							
								
								
									
										28
									
								
								Grabby.c
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								Grabby.c
									
									
									
									
									
								
							| 
						 | 
					@ -59,8 +59,14 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
 | 
				
			||||||
                     LPTSTR    lpCmdLine,
 | 
					                     LPTSTR    lpCmdLine,
 | 
				
			||||||
                     int       nCmdShow)
 | 
					                     int       nCmdShow)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						SYSTEMTIME stNow = {0};
 | 
				
			||||||
	RECT capRegion = {0};
 | 
						RECT capRegion = {0};
 | 
				
			||||||
	Screen *scrn = CreateScreen();
 | 
						Screen *scrn = CreateScreen();
 | 
				
			||||||
 | 
					#define OUTPUT_DIR_LEN		96
 | 
				
			||||||
 | 
						TCHAR szOutputDir[OUTPUT_DIR_LEN + 1];
 | 
				
			||||||
 | 
					#define FULL_OUT_PATH_LEN	OUTPUT_DIR_LEN + 24
 | 
				
			||||||
 | 
						TCHAR szFullOutPath[FULL_OUT_PATH_LEN + 1];
 | 
				
			||||||
 | 
						HRESULT hRes;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!scrn) {
 | 
						if (!scrn) {
 | 
				
			||||||
		Die("Couldn't get screen information");
 | 
							Die("Couldn't get screen information");
 | 
				
			||||||
| 
						 | 
					@ -80,8 +86,28 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	GetChosenRect(&capRegion);
 | 
						GetChosenRect(&capRegion);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (!GetTempPath(OUTPUT_DIR_LEN, szOutputDir)) {
 | 
				
			||||||
 | 
							Die("Couldn't get temporary directory");
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (WriteRegionToFile(scrn, &capRegion, _T("test.bmp")) == -1) {
 | 
						GetLocalTime(&stNow);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						hRes = StringCchPrintf(szFullOutPath,
 | 
				
			||||||
 | 
							FULL_OUT_PATH_LEN,
 | 
				
			||||||
 | 
							"%s\\scrn_%04d%02d%02d_%02d%02d%02d.bmp",
 | 
				
			||||||
 | 
							szOutputDir,
 | 
				
			||||||
 | 
							stNow.wYear,
 | 
				
			||||||
 | 
							stNow.wMonth,
 | 
				
			||||||
 | 
							stNow.wDay,
 | 
				
			||||||
 | 
							stNow.wHour,
 | 
				
			||||||
 | 
							stNow.wMinute,
 | 
				
			||||||
 | 
							stNow.wSecond);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (FAILED(hRes)) {
 | 
				
			||||||
 | 
							Die("Couldn't create screenshot file path");
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (WriteRegionToFile(scrn, &capRegion, szFullOutPath) == -1) {
 | 
				
			||||||
		Die("Couldn't grab region of the screen");
 | 
							Die("Couldn't grab region of the screen");
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										2
									
								
								stdafx.h
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								stdafx.h
									
									
									
									
									
								
							| 
						 | 
					@ -16,4 +16,4 @@
 | 
				
			||||||
#include <stdio.h>
 | 
					#include <stdio.h>
 | 
				
			||||||
#include <tchar.h>
 | 
					#include <tchar.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// TODO: reference additional headers your program requires here
 | 
					#include <Strsafe.h>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue