1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2013 - TortoiseGit
4 // Copyright (C) 2003-2008 - TortoiseSVN
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include "TortoiseProc.h"
22 #include "SysImageList.h"
23 #include "..\Utils\CrashReport.h"
24 #include "CmdLineParser.h"
27 #include "PathUtils.h"
28 #include "UnicodeUtils.h"
29 #include "MessageBox.h"
30 //#include "libintl.h"
31 #include "DirFileEnum.h"
32 //#include "SoundUtils.h"
33 #include "GitAdminDir.h"
35 #include "SmartHandle.h"
36 #include "Commands\Command.h"
37 #include "..\version.h"
38 #include "JumpListHelpers.h"
39 #include "SinglePropSheetDlg.h"
40 #include "Settings\setmainpage.h"
41 #include "..\Settings\Settings.h"
43 #include "Libraries.h"
44 #include "TaskbarUUID.h"
45 #include "GitConfig.h"
46 #include "SoundUtils.h"
48 #define STRUCT_IOVEC_DEFINED
54 #pragma comment(linker, "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
56 BEGIN_MESSAGE_MAP(CTortoiseProcApp
, CWinAppEx
)
57 ON_COMMAND(ID_HELP
, CWinAppEx::OnHelp
)
61 //CString CGit::m_MsysGitPath;
62 //////////////////////////////////////////////////////////////////////////
64 CTortoiseProcApp::CTortoiseProcApp()
67 // prevent from inheriting %GIT_DIR% from parent process by resetting it,
68 // use MSVC function instead of Windows API because MSVC runtime caches environment variables
69 _tputenv(_T("GIT_DIR="));
70 CCrashReport::Instance().AddUserInfoToReport(L
"CommandLine", GetCommandLine());
73 // const char* const * argv = NULL;
76 m_bLoadUserToolbars
= FALSE
;
79 m_gdiplusToken
= NULL
;
83 CTortoiseProcApp::~CTortoiseProcApp()
86 SYS_IMAGE_LIST().Cleanup();
89 // The one and only CTortoiseProcApp object
90 CTortoiseProcApp theApp
;
92 CString g_sGroupingUUID
;
95 BOOL
CTortoiseProcApp::CheckMsysGitDir()
97 //CGitIndexFileMap map;
100 //path.SetFromGit(_T("src/gpl.txt"));
101 //map.GetFileStatus(_T("D:\\TortoiseGit"),&path, &status);
102 return g_Git
.CheckMsysGitDir();
104 CCrashReportTGit
crasher(L
"TortoiseGit " _T(APP_X64_STRING
), TGIT_VERMAJOR
, TGIT_VERMINOR
, TGIT_VERMICRO
, TGIT_VERBUILD
, TGIT_VERDATE
);
106 // CTortoiseProcApp initialization
108 BOOL
CTortoiseProcApp::InitInstance()
111 CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows
));
112 CMFCButton::EnableWindowsTheming();
114 Gdiplus::GdiplusStartupInput gdiplusStartupInput
;
115 Gdiplus::GdiplusStartup(&m_gdiplusToken
,&gdiplusStartupInput
,NULL
);
117 //set the resource dll for the required language
118 CRegDWORD loc
= CRegDWORD(_T("Software\\TortoiseGit\\LanguageID"), 1033);
121 CStringA langpath
= CStringA(CPathUtils::GetAppParentDirectory());
122 langpath
+= "Languages";
123 // bindtextdomain("subversion", (LPCSTR)langpath);
124 // bind_textdomain_codeset("subversion", "UTF-8");
125 HINSTANCE hInst
= NULL
;
128 langDll
.Format(_T("%sLanguages\\TortoiseProc%d.dll"), (LPCTSTR
)CPathUtils::GetAppParentDirectory(), langId
);
130 hInst
= LoadLibrary(langDll
);
132 CString sVer
= _T(STRPRODUCTVER
);
133 CString sFileVer
= CPathUtils::GetVersionFromFile(langDll
);
134 if (sFileVer
.Compare(sVer
)!=0)
141 AfxSetResourceHandle(hInst
);
145 DWORD lid
= SUBLANGID(langId
);
149 langId
= MAKELANGID(PRIMARYLANGID(langId
), lid
);
154 } while ((hInst
== NULL
) && (langId
!= 0));
156 _tcscpy_s(buf
, _T("en"));
158 // MFC uses a help file with the same name as the application by default,
159 // which means we have to change that default to our language specific help files
160 CString sHelppath
= CPathUtils::GetAppDirectory() + _T("TortoiseGit_en.chm");
161 free((void*)m_pszHelpFilePath
);
162 m_pszHelpFilePath
=_tcsdup(sHelppath
);
163 sHelppath
= CPathUtils::GetAppParentDirectory() + _T("Languages\\TortoiseGit_en.chm");
166 CString sLang
= _T("_");
167 if (GetLocaleInfo(MAKELCID(langId
, SORT_DEFAULT
), LOCALE_SISO639LANGNAME
, buf
, _countof(buf
)))
170 sHelppath
.Replace(_T("_en"), sLang
);
171 if (PathFileExists(sHelppath
))
173 free((void*)m_pszHelpFilePath
);
174 m_pszHelpFilePath
=_tcsdup(sHelppath
);
178 sHelppath
.Replace(sLang
, _T("_en"));
179 if (GetLocaleInfo(MAKELCID(langId
, SORT_DEFAULT
), LOCALE_SISO3166CTRYNAME
, buf
, _countof(buf
)))
183 sHelppath
.Replace(_T("_en"), sLang
);
184 if (PathFileExists(sHelppath
))
186 free((void*)m_pszHelpFilePath
);
187 m_pszHelpFilePath
=_tcsdup(sHelppath
);
191 sHelppath
.Replace(sLang
, _T("_en"));
193 DWORD lid
= SUBLANGID(langId
);
197 langId
= MAKELANGID(PRIMARYLANGID(langId
), lid
);
202 setlocale(LC_ALL
, "");
204 if(!CheckMsysGitDir())
206 UINT ret
= CMessageBox::Show(NULL
, IDS_PROC_NOMSYSGIT
, IDS_APPNAME
, 3, IDI_HAND
, IDS_PROC_SETMSYSGITPATH
, IDS_PROC_GOTOMSYSGITWEBSITE
, IDS_ABORTBUTTON
);
209 ShellExecute(NULL
, NULL
, _T("http://code.google.com/p/msysgit/"), NULL
, NULL
, SW_SHOW
);
213 // open settings dialog
214 CSinglePropSheetDlg(CString(MAKEINTRESOURCE(IDS_PROC_SETTINGS_TITLE
)), new CSetMainPage(), this->GetMainWnd()).DoModal();
218 if (CAppUtils::GetMsysgitVersion() < 0x01070a00)
220 int ret
= CMessageBox::ShowCheck(NULL
, IDS_PROC_OLDMSYSGIT
, IDS_APPNAME
, 1, IDI_EXCLAMATION
, IDS_PROC_GOTOMSYSGITWEBSITE
, IDS_ABORTBUTTON
, IDS_IGNOREBUTTON
, _T("OldMsysgitVersionWarning"), IDS_PROC_NOTSHOWAGAINIGNORE
);
223 CMessageBox::RemoveRegistryKey(_T("OldMsysgitVersionWarning")); // only store answer if it is "Ignore"
224 ShellExecute(NULL
, NULL
, _T("http://code.google.com/p/msysgit/"), NULL
, NULL
, SW_SHOW
);
229 CMessageBox::RemoveRegistryKey(_T("OldMsysgitVersionWarning")); // only store answer if it is "Ignore"
234 // InitCommonControls() is required on Windows XP if an application
235 // manifest specifies use of ComCtl32.dll version 6 or later to enable
236 // visual styles. Otherwise, any window creation will fail.
238 INITCOMMONCONTROLSEX used
= {
239 sizeof(INITCOMMONCONTROLSEX
),
240 ICC_ANIMATE_CLASS
| ICC_BAR_CLASSES
| ICC_COOL_CLASSES
| ICC_DATE_CLASSES
|
241 ICC_HOTKEY_CLASS
| ICC_INTERNET_CLASSES
| ICC_LISTVIEW_CLASSES
|
242 ICC_NATIVEFNTCTL_CLASS
| ICC_PAGESCROLLER_CLASS
| ICC_PROGRESS_CLASS
|
243 ICC_TAB_CLASSES
| ICC_TREEVIEW_CLASSES
| ICC_UPDOWN_CLASS
|
244 ICC_USEREX_CLASSES
| ICC_WIN95_CLASSES
246 InitCommonControlsEx(&used
);
248 AfxEnableControlContainer();
250 CWinAppEx::InitInstance();
251 SetRegistryKey(_T("TortoiseGit"));
252 AfxGetApp()->m_pszProfileName
= _tcsdup(_T("TortoiseProc")); // w/o this ResizableLib will store data under TortoiseGitProc which is not compatible with older versions
254 CCmdLineParser
parser(AfxGetApp()->m_lpCmdLine
);
257 CString sVal
= parser
.GetVal(_T("hwnd"));
259 hWndExplorer
= (HWND
)_ttoi64(sVal
);
261 while (GetParent(hWndExplorer
)!=NULL
)
262 hWndExplorer
= GetParent(hWndExplorer
);
263 if (!IsWindow(hWndExplorer
))
268 // if HKCU\Software\TortoiseGit\Debug is not 0, show our command line
270 if (CRegDWORD(_T("Software\\TortoiseGit\\Debug"), FALSE
)==TRUE
)
271 AfxMessageBox(AfxGetApp()->m_lpCmdLine
, MB_OK
| MB_ICONINFORMATION
);
273 if ( parser
.HasKey(_T("path")) && parser
.HasKey(_T("pathfile")))
275 CMessageBox::Show(NULL
, IDS_ERR_INVALIDPATH
, IDS_APPNAME
, MB_ICONERROR
);
279 CTGitPath cmdLinePath
;
280 CTGitPathList pathList
;
281 if (g_sGroupingUUID
.IsEmpty())
282 g_sGroupingUUID
= parser
.GetVal(L
"groupuuid");
283 if ( parser
.HasKey(_T("pathfile")) )
286 CString sPathfileArgument
= CPathUtils::GetLongPathname(parser
.GetVal(_T("pathfile")));
288 cmdLinePath
.SetFromUnknown(sPathfileArgument
);
289 if (pathList
.LoadFromFile(cmdLinePath
)==false)
290 return FALSE
; // no path specified!
291 if ( parser
.HasKey(_T("deletepathfile")) )
293 // We can delete the temporary path file, now that we've loaded it
294 ::DeleteFile(cmdLinePath
.GetWinPath());
296 // This was a path to a temporary file - it's got no meaning now, and
297 // anybody who uses it again is in for a problem...
304 CString sPathArgument
= CPathUtils::GetLongPathname(parser
.GetVal(_T("path")));
305 if (parser
.HasKey(_T("expaths")))
307 // an /expaths param means we're started via the buttons in our Win7 library
308 // and that means the value of /expaths is the current directory, and
309 // the selected paths are then added as additional parameters but without a key, only a value
311 // because of the "strange treatment of quotation marks and backslashes by CommandLineToArgvW"
312 // we have to escape the backslashes first. Since we're only dealing with paths here, that's
314 // Without this, a command line like:
315 // /command:commit /expaths:"D:\" "D:\Utils"
316 // would fail because the "D:\" is treated as the backslash being the escape char for the quotation
317 // mark and we'd end up with:
318 // argv[1] = /command:commit
319 // argv[2] = /expaths:D:" D:\Utils
320 // See here for more details: http://blogs.msdn.com/b/oldnewthing/archive/2010/09/17/10063629.aspx
321 CString cmdLine
= GetCommandLineW();
322 cmdLine
.Replace(L
"\\", L
"\\\\");
324 LPWSTR
*szArglist
= CommandLineToArgvW(cmdLine
, &nArgs
);
327 // argument 0 is the process path, so start with 1
328 for (int i
= 1; i
< nArgs
; ++i
)
330 if (szArglist
[i
][0] != '/')
332 if (!sPathArgument
.IsEmpty())
333 sPathArgument
+= '*';
334 sPathArgument
+= szArglist
[i
];
337 sPathArgument
.Replace(L
"\\\\", L
"\\");
339 LocalFree(szArglist
);
341 if (sPathArgument
.IsEmpty() && parser
.HasKey(L
"path"))
343 CMessageBox::Show(hWndExplorer
, IDS_ERR_INVALIDPATH
, IDS_APPNAME
, MB_ICONERROR
);
346 int asterisk
= sPathArgument
.Find('*');
347 cmdLinePath
.SetFromUnknown(asterisk
>= 0 ? sPathArgument
.Left(asterisk
) : sPathArgument
);
348 pathList
.LoadFromAsteriskSeparatedString(sPathArgument
);
351 if (pathList
.GetCount() == 0) {
352 pathList
.AddPath(CTGitPath::CTGitPath(g_Git
.m_CurrentDir
));
355 // Subversion sometimes writes temp files to the current directory!
356 // Since TSVN doesn't need a specific CWD anyway, we just set it
357 // to the users temp folder: that way, Subversion is guaranteed to
358 // have write access to the CWD
360 DWORD len
= GetCurrentDirectory(0, NULL
);
363 std::unique_ptr
<TCHAR
[]> originalCurrentDirectory(new TCHAR
[len
]);
364 if (GetCurrentDirectory(len
, originalCurrentDirectory
.get()))
366 sOrigCWD
= originalCurrentDirectory
.get();
367 sOrigCWD
= CPathUtils::GetLongPathname(sOrigCWD
);
370 TCHAR pathbuf
[MAX_PATH
];
371 GetTortoiseGitTempPath(MAX_PATH
, pathbuf
);
372 SetCurrentDirectory(pathbuf
);
375 CheckForNewerVersion();
377 if (parser
.HasVal(_T("configdir")))
379 // the user can override the location of the Subversion config directory here
380 CString sConfigDir
= parser
.GetVal(_T("configdir"));
381 // g_GitGlobal.SetConfigDir(sConfigDir);
384 CAutoGeneralHandle TGitMutex
= ::CreateMutex(NULL
, FALSE
, _T("TortoiseGitProc.exe"));
385 if (!g_Git
.SetCurrentDir(cmdLinePath
.GetWinPathString(), parser
.HasKey(_T("submodule")) == TRUE
))
387 for (int i
= 0; i
< pathList
.GetCount(); ++i
)
388 if(g_Git
.SetCurrentDir(pathList
[i
].GetWinPath()))
392 if(!g_Git
.m_CurrentDir
.IsEmpty())
394 sOrigCWD
= g_Git
.m_CurrentDir
;
395 SetCurrentDirectory(g_Git
.m_CurrentDir
);
398 if (g_sGroupingUUID
.IsEmpty())
400 CRegStdDWORD groupSetting
= CRegStdDWORD(_T("Software\\TortoiseGit\\GroupTaskbarIconsPerRepo"), 3);
401 switch (DWORD(groupSetting
))
405 // implemented differently to TortoiseSVN atm
411 if (g_GitAdminDir
.HasAdminDir(g_Git
.m_CurrentDir
, true, &wcroot
))
414 CStringA
wcRootA(wcroot
);
415 if (!git_odb_hash(&oid
, wcRootA
.GetBuffer(), wcRootA
.GetLength(), GIT_OBJ_BLOB
))
418 git_oid_tostr(hash
.GetBufferSetLength(GIT_OID_HEXSZ
+ 1), GIT_OID_HEXSZ
+ 1, &oid
);
419 hash
.ReleaseBuffer();
420 g_sGroupingUUID
= hash
;
427 CString sAppID
= GetTaskIDPerUUID(g_sGroupingUUID
).c_str();
428 InitializeJumpList(sAppID
);
429 EnsureGitLibrary(false);
435 // requires CWD to be set
436 CGit::m_LogEncode
= CAppUtils::GetLogOutputEncode();
438 // make sure all config files are read in order to check that none contains an error
439 g_Git
.GetConfigValue(_T("doesnot.exist"));
448 UINT choice
= CMessageBox::Show(hWndExplorer
, err
, _T("TortoiseGit"), 1, IDI_ERROR
, CString(MAKEINTRESOURCE(IDS_PROC_EDITLOCALGITCONFIG
)), CString(MAKEINTRESOURCE(IDS_PROC_EDITGLOBALGITCONFIG
)), CString(MAKEINTRESOURCE(IDS_ABORTBUTTON
)));
451 // open the config file with alternative editor
452 CAppUtils::LaunchAlternativeEditor(g_Git
.GetGitLocalConfig());
454 else if (choice
== 2)
456 // open the global config file with alternative editor
457 CAppUtils::LaunchAlternativeEditor(g_Git
.GetGitGlobalConfig());
463 // execute the requested command
464 CommandServer server
;
465 Command
* cmd
= server
.GetCommand(parser
.GetVal(_T("command")));
468 cmd
->SetExplorerHwnd(hWndExplorer
);
470 cmd
->SetParser(parser
);
471 cmd
->SetPaths(pathList
, cmdLinePath
);
473 retSuccess
= cmd
->Execute();
477 // Look for temporary files left around by TortoiseSVN and
478 // remove them. But only delete 'old' files because some
479 // apps might still be needing the recent ones.
481 DWORD len
= GetTortoiseGitTempPath(0, NULL
);
482 std::unique_ptr
<TCHAR
[]> path(new TCHAR
[len
+ 100]);
483 len
= GetTortoiseGitTempPath (len
+ 100, path
.get());
486 CDirFileEnum
finder(path
.get());
488 ::GetSystemTimeAsFileTime(&systime_
);
489 __int64 systime
= (((_int64
)systime_
.dwHighDateTime
)<<32) | ((__int64
)systime_
.dwLowDateTime
);
492 while (finder
.NextFile(filepath
, &isDir
))
494 HANDLE hFile
= ::CreateFile(filepath
, GENERIC_READ
, FILE_SHARE_READ
, NULL
, OPEN_EXISTING
, isDir
? FILE_FLAG_BACKUP_SEMANTICS
: NULL
, NULL
);
495 if (hFile
!= INVALID_HANDLE_VALUE
)
497 FILETIME createtime_
;
498 if (::GetFileTime(hFile
, &createtime_
, NULL
, NULL
))
500 ::CloseHandle(hFile
);
501 __int64 createtime
= (((_int64
)createtime_
.dwHighDateTime
)<<32) | ((__int64
)createtime_
.dwLowDateTime
);
502 if ((createtime
+ 864000000000) < systime
) //only delete files older than a day
504 ::SetFileAttributes(filepath
, FILE_ATTRIBUTE_NORMAL
);
506 ::RemoveDirectory(filepath
);
508 ::DeleteFile(filepath
);
512 ::CloseHandle(hFile
);
518 // Since the dialog has been closed, return FALSE so that we exit the
519 // application, rather than start the application's message pump.
523 void CTortoiseProcApp::CheckUpgrade()
525 CRegString regVersion
= CRegString(_T("Software\\TortoiseGit\\CurrentVersion"));
526 CString sVersion
= regVersion
;
527 if (sVersion
.Compare(_T(STRPRODUCTVER
))==0)
529 // we're starting the first time with a new version!
532 int pos
= sVersion
.Find('.');
535 lVersion
= (_ttol(sVersion
.Left(pos
))<<24);
536 lVersion
|= (_ttol(sVersion
.Mid(pos
+1))<<16);
537 pos
= sVersion
.Find('.', pos
+1);
538 lVersion
|= (_ttol(sVersion
.Mid(pos
+1))<<8);
542 pos
= sVersion
.Find(',');
545 lVersion
= (_ttol(sVersion
.Left(pos
))<<24);
546 lVersion
|= (_ttol(sVersion
.Mid(pos
+1))<<16);
547 pos
= sVersion
.Find(',', pos
+1);
548 lVersion
|= (_ttol(sVersion
.Mid(pos
+1))<<8);
552 if (lVersion
<= 0x01080202)
554 CSoundUtils::RegisterTGitSounds();
555 // upgrade to 1.8.3: force recreation of all diff scripts.
556 CAppUtils::SetupDiffScripts(true, CString());
559 if (lVersion
<= 0x01080100)
561 if (CRegStdDWORD(_T("Software\\TortoiseGit\\LogTopoOrder"), TRUE
) == FALSE
)
562 CRegStdDWORD(_T("Software\\TortoiseGit\\LogOrderBy")) = 0;
564 // smoothly migrate broken msysgit path settings
565 CString oldmsysGitSetting
= CRegString(REG_MSYSGIT_PATH
);
566 oldmsysGitSetting
.TrimRight(_T("\\"));
567 CString right
= oldmsysGitSetting
.Right(4);
568 if (oldmsysGitSetting
.GetLength() > 4 && oldmsysGitSetting
.Right(4) == _T("\\cmd"))
570 CString newPath
= oldmsysGitSetting
.Mid(0, oldmsysGitSetting
.GetLength() - 3) + _T("bin");
571 if (PathFileExists(newPath
+ _T("\\git.exe")))
573 CRegString(REG_MSYSGIT_PATH
) = newPath
;
574 g_Git
.m_bInitialized
= FALSE
;
575 g_Git
.CheckMsysGitDir();
580 if (lVersion
<= 0x01040000)
582 CRegStdDWORD(_T("Software\\TortoiseGit\\OwnerdrawnMenus")).removeValue();
585 if (lVersion
<= 0x01070600)
590 CRegStdDWORD(_T("Software\\TortoiseGit\\ConvertBase")).removeValue();
591 CRegStdDWORD(_T("Software\\TortoiseGit\\DiffProps")).removeValue();
592 if (CRegStdDWORD(_T("Software\\TortoiseGit\\CheckNewer"), TRUE
) == FALSE
)
593 CRegStdDWORD(_T("Software\\TortoiseGit\\VersionCheck")) = FALSE
;
596 if (lVersion
<= 0x01070E00)
598 CRegStdDWORD(_T("Software\\TortoiseGit\\CheckNewer")).removeValue();
600 CAppUtils::SetupDiffScripts(false, CString());
602 // set the current version so we don't come here again until the next update!
603 regVersion
= _T(STRPRODUCTVER
);
606 void CTortoiseProcApp::InitializeJumpList(const CString
& appid
)
608 // for Win7 : use a custom jump list
611 DeleteJumpList(appid
);
612 DoInitializeJumpList(appid
);
616 void CTortoiseProcApp::DoInitializeJumpList(const CString
& appid
)
618 ATL::CComPtr
<ICustomDestinationList
> pcdl
;
619 HRESULT hr
= pcdl
.CoCreateInstance(CLSID_DestinationList
, NULL
, CLSCTX_INPROC_SERVER
);
623 hr
= pcdl
->SetAppID(appid
);
628 ATL::CComPtr
<IObjectArray
> poaRemoved
;
629 hr
= pcdl
->BeginList(&uMaxSlots
, IID_PPV_ARGS(&poaRemoved
));
633 ATL::CComPtr
<IObjectCollection
> poc
;
634 hr
= poc
.CoCreateInstance(CLSID_EnumerableObjectCollection
, NULL
, CLSCTX_INPROC_SERVER
);
638 CString sTemp
= CString(MAKEINTRESOURCE(IDS_MENUSETTINGS
));
641 ATL::CComPtr
<IShellLink
> psl
;
642 hr
= CreateShellLink(_T("/command:settings"), (LPCTSTR
)sTemp
, 20, &psl
);
646 sTemp
= CString(MAKEINTRESOURCE(IDS_MENUHELP
));
648 psl
.Release(); // Need to release the object before calling operator&()
649 hr
= CreateShellLink(_T("/command:help"), (LPCTSTR
)sTemp
, 19, &psl
);
654 ATL::CComPtr
<IObjectArray
> poa
;
655 hr
= poc
.QueryInterface(&poa
);
657 pcdl
->AppendCategory((LPCTSTR
)CString(MAKEINTRESOURCE(IDS_PROC_TASKS
)), poa
);
662 int CTortoiseProcApp::ExitInstance()
664 Gdiplus::GdiplusShutdown(m_gdiplusToken
);
666 CWinAppEx::ExitInstance();
672 void CTortoiseProcApp::CheckForNewerVersion()
674 // check for newer versions
675 if (CRegDWORD(_T("Software\\TortoiseGit\\VersionCheck"), TRUE
) != FALSE
)
681 if ((now
!= 0) && (localtime_s(&ptm
, &now
)==0))
684 // Check daily for new preview releases
685 CRegDWORD oldday
= CRegDWORD(_T("Software\\TortoiseGit\\CheckNewerDay"), (DWORD
)-1);
686 if (((DWORD
)oldday
) == -1)
687 oldday
= ptm
.tm_yday
;
690 if ((DWORD
)oldday
!= (DWORD
)ptm
.tm_yday
)
692 oldday
= ptm
.tm_yday
;
695 // we don't calculate the real 'week of the year' here
696 // because just to decide if we should check for an update
697 // that's not needed.
698 week
= ptm
.tm_yday
/ 7;
700 CRegDWORD oldweek
= CRegDWORD(_T("Software\\TortoiseGit\\CheckNewerWeek"), (DWORD
)-1);
701 if (((DWORD
)oldweek
) == -1)
702 oldweek
= week
; // first start of TortoiseProc, no update check needed
705 if ((DWORD
)week
!= oldweek
)
709 CAppUtils::RunTortoiseGitProc(_T("/command:updatecheck"), false, false);