1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2012 - 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.
22 #include "TortoiseProc.h"
23 #include "SysImageList.h"
24 #include "CrashReport.h"
25 #include "CmdLineParser.h"
28 #include "PathUtils.h"
29 #include "UnicodeUtils.h"
30 #include "MessageBox.h"
31 //#include "libintl.h"
32 #include "DirFileEnum.h"
33 //#include "SoundUtils.h"
35 #include "GitAdminDir.h"
37 //#include "SVNGlobal.h"
38 //#include "svn_types.h"
39 //#include "svn_dso.h"
40 //#include <openssl/ssl.h>
41 //#include <openssl/err.h>
42 #include "SmartHandle.h"
43 #include "Commands\Command.h"
44 #include "..\version.h"
45 #include "JumpListHelpers.h"
46 #include "..\Settings\Settings.h"
48 #include "Libraries.h"
50 #define STRUCT_IOVEC_DEFINED
57 #pragma comment(linker, "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
59 #define APPID (_T("TGIT.TGIT.1") _T(TGIT_PLATFORM))
61 BEGIN_MESSAGE_MAP(CTortoiseProcApp
, CWinAppEx
)
62 ON_COMMAND(ID_HELP
, CWinAppEx::OnHelp
)
66 //CString CGit::m_MsysGitPath;
67 //////////////////////////////////////////////////////////////////////////
69 CTortoiseProcApp::CTortoiseProcApp()
74 // const char* const * argv = NULL;
75 // apr_app_initialize(&argc, &argv, NULL);
76 // svn_dso_initialize2();
80 m_bLoadUserToolbars
= FALSE
;
86 CTortoiseProcApp::~CTortoiseProcApp()
88 // global application exit cleanup (after all SSL activity is shutdown)
89 // we have to clean up SSL ourselves, since neon doesn't do that (can't do it)
90 // because those cleanup functions work globally per process.
93 //CRYPTO_cleanup_all_ex_data();
95 // since it is undefined *when* the global object SVNAdminDir is
96 // destroyed, we tell it to destroy the memory pools and terminate apr
97 // *now* instead of later when the object itself is destroyed.
98 g_GitAdminDir
.Close();
100 SYS_IMAGE_LIST().Cleanup();
104 // The one and only CTortoiseProcApp object
105 CTortoiseProcApp theApp
;
109 BOOL
CTortoiseProcApp::CheckMsysGitDir()
111 //CGitIndexFileMap map;
114 //path.SetFromGit(_T("src/gpl.txt"));
115 //map.GetFileStatus(_T("D:\\TortoiseGit"),&path, &status);
116 return g_Git
.CheckMsysGitDir();
118 CCrashReport
crasher("tortoisegit-bug@googlegroups.com", "Crash Report for TortoiseGit " APP_X64_STRING
" : " STRPRODUCTVER
, TRUE
);// crash
120 // CTortoiseProcApp initialization
122 BOOL
CTortoiseProcApp::InitInstance()
124 EnableCrashHandler();
126 CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows
));
127 CMFCButton::EnableWindowsTheming();
129 Gdiplus::GdiplusStartupInput gdiplusStartupInput
;
130 Gdiplus::GdiplusStartup(&m_gdiplusToken
,&gdiplusStartupInput
,NULL
);
132 if(!CheckMsysGitDir())
134 UINT ret
= CMessageBox::Show(NULL
,_T("MSysGit (http://code.google.com/p/msysgit/) not found."),
135 _T("TortoiseGit"), 3, IDI_HAND
, _T("&Set MSysGit path"), _T("&Goto WebSite"), _T("&Abort"));
138 ShellExecute(NULL
, NULL
, _T("http://code.google.com/p/msysgit/"), NULL
, NULL
, SW_SHOW
);
142 // open settings dialog
143 CSettings
dlg(IDS_PROC_SETTINGS_TITLE
);
144 dlg
.SetTreeViewMode(TRUE
, TRUE
, TRUE
);
145 dlg
.SetTreeWidth(220);
153 //set the resource dll for the required language
154 CRegDWORD loc
= CRegDWORD(_T("Software\\TortoiseGit\\LanguageID"), 1033);
157 CStringA langpath
= CStringA(CPathUtils::GetAppParentDirectory());
158 langpath
+= "Languages";
159 // bindtextdomain("subversion", (LPCSTR)langpath);
160 // bind_textdomain_codeset("subversion", "UTF-8");
161 HINSTANCE hInst
= NULL
;
164 langDll
.Format(_T("%sLanguages\\TortoiseProc%d.dll"), (LPCTSTR
)CPathUtils::GetAppParentDirectory(), langId
);
166 hInst
= LoadLibrary(langDll
);
168 CString sVer
= _T(STRPRODUCTVER
);
169 CString sFileVer
= CPathUtils::GetVersionFromFile(langDll
);
170 if (sFileVer
.Compare(sVer
)!=0)
177 AfxSetResourceHandle(hInst
);
181 DWORD lid
= SUBLANGID(langId
);
185 langId
= MAKELANGID(PRIMARYLANGID(langId
), lid
);
190 } while ((hInst
== NULL
) && (langId
!= 0));
192 _tcscpy_s(buf
, _T("en"));
195 sHelppath
= this->m_pszHelpFilePath
;
196 sHelppath
= sHelppath
.MakeLower();
197 // MFC uses a help file with the same name as the application by default,
198 // which means we have to change that default to our language specific help files
199 sHelppath
.Replace(_T("tortoiseproc.chm"), _T("TortoiseGit_en.chm"));
200 free((void*)m_pszHelpFilePath
);
201 m_pszHelpFilePath
=_tcsdup(sHelppath
);
202 sHelppath
= CPathUtils::GetAppParentDirectory() + _T("Languages\\TortoiseGit_en.chm");
205 CString sLang
= _T("_");
206 if (GetLocaleInfo(MAKELCID(langId
, SORT_DEFAULT
), LOCALE_SISO639LANGNAME
, buf
, _countof(buf
)))
209 sHelppath
.Replace(_T("_en"), sLang
);
210 if (PathFileExists(sHelppath
))
212 free((void*)m_pszHelpFilePath
);
213 m_pszHelpFilePath
=_tcsdup(sHelppath
);
217 sHelppath
.Replace(sLang
, _T("_en"));
218 if (GetLocaleInfo(MAKELCID(langId
, SORT_DEFAULT
), LOCALE_SISO3166CTRYNAME
, buf
, _countof(buf
)))
222 sHelppath
.Replace(_T("_en"), sLang
);
223 if (PathFileExists(sHelppath
))
225 free((void*)m_pszHelpFilePath
);
226 m_pszHelpFilePath
=_tcsdup(sHelppath
);
230 sHelppath
.Replace(sLang
, _T("_en"));
232 DWORD lid
= SUBLANGID(langId
);
236 langId
= MAKELANGID(PRIMARYLANGID(langId
), lid
);
241 setlocale(LC_ALL
, "");
243 // InitCommonControls() is required on Windows XP if an application
244 // manifest specifies use of ComCtl32.dll version 6 or later to enable
245 // visual styles. Otherwise, any window creation will fail.
247 INITCOMMONCONTROLSEX used
= {
248 sizeof(INITCOMMONCONTROLSEX
),
249 ICC_ANIMATE_CLASS
| ICC_BAR_CLASSES
| ICC_COOL_CLASSES
| ICC_DATE_CLASSES
|
250 ICC_HOTKEY_CLASS
| ICC_INTERNET_CLASSES
| ICC_LISTVIEW_CLASSES
|
251 ICC_NATIVEFNTCTL_CLASS
| ICC_PAGESCROLLER_CLASS
| ICC_PROGRESS_CLASS
|
252 ICC_TAB_CLASSES
| ICC_TREEVIEW_CLASSES
| ICC_UPDOWN_CLASS
|
253 ICC_USEREX_CLASSES
| ICC_WIN95_CLASSES
255 InitCommonControlsEx(&used
);
257 AfxEnableControlContainer();
259 CWinAppEx::InitInstance();
260 SetRegistryKey(_T("TortoiseGit"));
262 CCmdLineParser
parser(AfxGetApp()->m_lpCmdLine
);
265 CString sVal
= parser
.GetVal(_T("hwnd"));
267 hWndExplorer
= (HWND
)_ttoi64(sVal
);
269 while (GetParent(hWndExplorer
)!=NULL
)
270 hWndExplorer
= GetParent(hWndExplorer
);
271 if (!IsWindow(hWndExplorer
))
276 // if HKCU\Software\TortoiseGit\Debug is not 0, show our command line
278 if (CRegDWORD(_T("Software\\TortoiseGit\\Debug"), FALSE
)==TRUE
)
279 AfxMessageBox(AfxGetApp()->m_lpCmdLine
, MB_OK
| MB_ICONINFORMATION
);
281 if ( parser
.HasKey(_T("path")) && parser
.HasKey(_T("pathfile")))
283 CMessageBox::Show(NULL
, IDS_ERR_INVALIDPATH
, IDS_APPNAME
, MB_ICONERROR
);
287 CTGitPath cmdLinePath
;
288 CTGitPathList pathList
;
289 if ( parser
.HasKey(_T("pathfile")) )
292 CString sPathfileArgument
= CPathUtils::GetLongPathname(parser
.GetVal(_T("pathfile")));
294 cmdLinePath
.SetFromUnknown(sPathfileArgument
);
295 if (pathList
.LoadFromFile(cmdLinePath
)==false)
296 return FALSE
; // no path specified!
297 if ( parser
.HasKey(_T("deletepathfile")) )
299 // We can delete the temporary path file, now that we've loaded it
300 ::DeleteFile(cmdLinePath
.GetWinPath());
302 // This was a path to a temporary file - it's got no meaning now, and
303 // anybody who uses it again is in for a problem...
310 CString sPathArgument
= CPathUtils::GetLongPathname(parser
.GetVal(_T("path")));
311 if (parser
.HasKey(_T("expaths")))
313 // an /expaths param means we're started via the buttons in our Win7 library
314 // and that means the value of /expaths is the current directory, and
315 // the selected paths are then added as additional parameters but without a key, only a value
317 // because of the "strange treatment of quotation marks and backslashes by CommandLineToArgvW"
318 // we have to escape the backslashes first. Since we're only dealing with paths here, that's
320 // Without this, a command line like:
321 // /command:commit /expaths:"D:\" "D:\Utils"
322 // would fail because the "D:\" is treated as the backslash being the escape char for the quotation
323 // mark and we'd end up with:
324 // argv[1] = /command:commit
325 // argv[2] = /expaths:D:" D:\Utils
326 // See here for more details: http://blogs.msdn.com/b/oldnewthing/archive/2010/09/17/10063629.aspx
327 CString cmdLine
= GetCommandLineW();
328 cmdLine
.Replace(L
"\\", L
"\\\\");
330 LPWSTR
*szArglist
= CommandLineToArgvW(cmdLine
, &nArgs
);
333 // argument 0 is the process path, so start with 1
334 for (int i
=1; i
<nArgs
; i
++)
336 if (szArglist
[i
][0] != '/')
338 if (!sPathArgument
.IsEmpty())
339 sPathArgument
+= '*';
340 sPathArgument
+= szArglist
[i
];
343 sPathArgument
.Replace(L
"\\\\", L
"\\");
345 LocalFree(szArglist
);
347 if (sPathArgument
.IsEmpty() && parser
.HasKey(L
"path"))
349 CMessageBox::Show(hWndExplorer
, IDS_ERR_INVALIDPATH
, IDS_APPNAME
, MB_ICONERROR
);
352 int asterisk
= sPathArgument
.Find('*');
353 cmdLinePath
.SetFromUnknown(asterisk
>= 0 ? sPathArgument
.Left(asterisk
) : sPathArgument
);
354 pathList
.LoadFromAsteriskSeparatedString(sPathArgument
);
357 if (pathList
.GetCount() == 0) {
358 pathList
.AddPath(CTGitPath::CTGitPath(g_Git
.m_CurrentDir
));
361 InitializeJumpList();
362 EnsureGitLibrary(false);
364 // Subversion sometimes writes temp files to the current directory!
365 // Since TSVN doesn't need a specific CWD anyway, we just set it
366 // to the users temp folder: that way, Subversion is guaranteed to
367 // have write access to the CWD
369 DWORD len
= GetCurrentDirectory(0, NULL
);
372 auto_buffer
<TCHAR
> originalCurrentDirectory(len
);
373 if (GetCurrentDirectory(len
, originalCurrentDirectory
))
375 sOrigCWD
= originalCurrentDirectory
;
376 sOrigCWD
= CPathUtils::GetLongPathname(sOrigCWD
);
379 TCHAR pathbuf
[MAX_PATH
];
380 GetTempPath(MAX_PATH
, pathbuf
);
381 SetCurrentDirectory(pathbuf
);
384 CheckForNewerVersion();
386 if (parser
.HasVal(_T("configdir")))
388 // the user can override the location of the Subversion config directory here
389 CString sConfigDir
= parser
.GetVal(_T("configdir"));
390 // g_GitGlobal.SetConfigDir(sConfigDir);
392 // to avoid that SASL will look for and load its plugin dlls all around the
393 // system, we set the path here.
394 // Note that SASL doesn't have to be initialized yet for this to work
395 // sasl_set_path(SASL_PATH_TYPE_PLUGIN, (LPSTR)(LPCSTR)CUnicodeUtils::GetUTF8(CPathUtils::GetAppDirectory().TrimRight('\\')));
397 CAutoGeneralHandle TGitMutex
= ::CreateMutex(NULL
, FALSE
, _T("TortoiseGitProc.exe"));
398 if(!g_Git
.SetCurrentDir(cmdLinePath
.GetWinPathString()))
401 for(i
=0;i
<pathList
.GetCount();i
++)
402 if(g_Git
.SetCurrentDir(pathList
[i
].GetWinPath()))
406 if(!g_Git
.m_CurrentDir
.IsEmpty())
408 sOrigCWD
= g_Git
.m_CurrentDir
;
409 SetCurrentDirectory(g_Git
.m_CurrentDir
);
416 // requires CWD to be set
417 CGit::m_LogEncode
= CAppUtils::GetLogOutputEncode();
426 UINT choice
= CMessageBox::Show(hWndExplorer
, err
, _T("TortoiseGit Error"), 1, IDI_ERROR
, _T("&Edit .git/config"), _T("Edit &global .gitconfig"), _T("&Abort"));
429 // open the config file with alternative editor
431 g_GitAdminDir
.GetAdminDirPath(g_Git
.m_CurrentDir
, path
);
432 path
+= _T("config");
433 CAppUtils::LaunchAlternativeEditor(path
);
435 else if (choice
== 2)
437 // open the global config file with alternative editor
438 char charBuf
[MAX_PATH
];
440 strcpy_s(charBuf
, MAX_PATH
, get_windows_home_directory());
441 _tcscpy_s(buf
, MAX_PATH
, CA2CT(charBuf
));
442 _tcscat_s(buf
, MAX_PATH
, _T("\\.gitconfig"));
443 CAppUtils::LaunchAlternativeEditor(buf
);
449 // execute the requested command
450 CommandServer server
;
451 Command
* cmd
= server
.GetCommand(parser
.GetVal(_T("command")));
454 cmd
->SetExplorerHwnd(hWndExplorer
);
456 cmd
->SetParser(parser
);
457 cmd
->SetPaths(pathList
, cmdLinePath
);
459 retSuccess
= cmd
->Execute();
463 // Look for temporary files left around by TortoiseSVN and
464 // remove them. But only delete 'old' files because some
465 // apps might still be needing the recent ones.
467 DWORD len
= ::GetTempPath(0, NULL
);
468 TCHAR
* path
= new TCHAR
[len
+ 100];
469 len
= ::GetTempPath (len
+100, path
);
472 CSimpleFileFind finder
= CSimpleFileFind(path
, _T("*svn*.*"));
474 ::GetSystemTimeAsFileTime(&systime_
);
475 __int64 systime
= (((_int64
)systime_
.dwHighDateTime
)<<32) | ((__int64
)systime_
.dwLowDateTime
);
476 while (finder
.FindNextFileNoDirectories())
478 CString filepath
= finder
.GetFilePath();
479 HANDLE hFile
= ::CreateFile(filepath
, GENERIC_READ
, FILE_SHARE_READ
, NULL
, OPEN_EXISTING
, NULL
, NULL
);
480 if (hFile
!= INVALID_HANDLE_VALUE
)
482 FILETIME createtime_
;
483 if (::GetFileTime(hFile
, &createtime_
, NULL
, NULL
))
485 ::CloseHandle(hFile
);
486 __int64 createtime
= (((_int64
)createtime_
.dwHighDateTime
)<<32) | ((__int64
)createtime_
.dwLowDateTime
);
487 if ((createtime
+ 864000000000) < systime
) //only delete files older than a day
489 ::SetFileAttributes(filepath
, FILE_ATTRIBUTE_NORMAL
);
490 ::DeleteFile(filepath
);
494 ::CloseHandle(hFile
);
501 // Since the dialog has been closed, return FALSE so that we exit the
502 // application, rather than start the application's message pump.
506 void CTortoiseProcApp::CheckUpgrade()
508 CRegString regVersion
= CRegString(_T("Software\\TortoiseGit\\CurrentVersion"));
509 CString sVersion
= regVersion
;
510 if (sVersion
.Compare(_T(STRPRODUCTVER
))==0)
512 // we're starting the first time with a new version!
515 int pos
= sVersion
.Find(',');
518 lVersion
= (_ttol(sVersion
.Left(pos
))<<24);
519 lVersion
|= (_ttol(sVersion
.Mid(pos
+1))<<16);
520 pos
= sVersion
.Find(',', pos
+1);
521 lVersion
|= (_ttol(sVersion
.Mid(pos
+1))<<8);
524 if (lVersion
<= 0x01070600)
529 CRegStdDWORD(_T("Software\\TortoiseGit\\ConvertBase")).removeValue();
530 CRegStdDWORD(_T("Software\\TortoiseGit\\DiffProps")).removeValue();
531 if (CRegStdDWORD(_T("Software\\TortoiseGit\\CheckNewer"), TRUE
) == FALSE
)
532 CRegStdDWORD(_T("Software\\TortoiseGit\\VersionCheck")) = FALSE
;
533 CRegStdDWORD(_T("Software\\TortoiseGit\\CheckNewer")).removeValue();
536 if (lVersion
<= 0x01010300)
538 CSoundUtils::RegisterTSVNSounds();
541 if (lVersion
<= 0x01020200)
543 // upgrade to > 1.2.3 means the doc diff scripts changed from vbs to js
544 // so remove the diff/merge scripts if they're the defaults
545 CRegString diffreg
= CRegString(_T("Software\\TortoiseGit\\DiffTools\\.doc"));
546 CString sDiff
= diffreg
;
547 CString sCL
= _T("wscript.exe \"") + CPathUtils::GetAppParentDirectory()+_T("Diff-Scripts\\diff-doc.vbs\"");
548 if (sDiff
.Left(sCL
.GetLength()).CompareNoCase(sCL
)==0)
550 CRegString mergereg
= CRegString(_T("Software\\TortoiseGit\\MergeTools\\.doc"));
552 sCL
= _T("wscript.exe \"") + CPathUtils::GetAppParentDirectory()+_T("Diff-Scripts\\merge-doc.vbs\"");
553 if (sDiff
.Left(sCL
.GetLength()).CompareNoCase(sCL
)==0)
556 if (lVersion
<= 0x01040000)
558 CRegStdDWORD(_T("Software\\TortoiseGit\\OwnerdrawnMenus")).removeValue();
561 // set the custom diff scripts for every user
562 CString scriptsdir
= CPathUtils::GetAppParentDirectory();
563 scriptsdir
+= _T("Diff-Scripts");
564 CSimpleFileFind
files(scriptsdir
);
565 while (files
.FindNextFileNoDirectories())
567 CString file
= files
.GetFilePath();
568 CString filename
= files
.GetFileName();
569 CString ext
= file
.Mid(file
.ReverseFind('-')+1);
570 ext
= _T(".")+ext
.Left(ext
.ReverseFind('.'));
572 if (file
.Right(3).CompareNoCase(_T("vbs"))==0)
574 kind
= _T(" //E:vbscript");
576 if (file
.Right(2).CompareNoCase(_T("js"))==0)
578 kind
= _T(" //E:javascript");
581 if (filename
.Left(5).CompareNoCase(_T("diff-"))==0)
583 CRegString diffreg
= CRegString(_T("Software\\TortoiseGit\\DiffTools\\")+ext
);
584 CString diffregstring
= diffreg
;
585 if ((diffregstring
.IsEmpty()) || (diffregstring
.Find(filename
)>=0))
586 diffreg
= _T("wscript.exe \"") + file
+ _T("\" %base %mine") + kind
;
588 if (filename
.Left(6).CompareNoCase(_T("merge-"))==0)
590 CRegString diffreg
= CRegString(_T("Software\\TortoiseGit\\MergeTools\\")+ext
);
591 CString diffregstring
= diffreg
;
592 if ((diffregstring
.IsEmpty()) || (diffregstring
.Find(filename
)>=0))
593 diffreg
= _T("wscript.exe \"") + file
+ _T("\" %merged %theirs %mine %base") + kind
;
597 // set the current version so we don't come here again until the next update!
598 regVersion
= _T(STRPRODUCTVER
);
601 void CTortoiseProcApp::EnableCrashHandler()
603 // the crash handler is enabled by default, but we disable it
604 // after 3 months after a release
606 #define YEAR ((((__DATE__ [7] - '0') * 10 + (__DATE__ [8] - '0')) * 10 \
607 + (__DATE__ [9] - '0')) * 10 + (__DATE__ [10] - '0'))
609 #define MONTH (__DATE__ [2] == 'n' ? (__DATE__ [1] == 'a' ? 1 : 6) \
610 : __DATE__ [2] == 'b' ? 2 \
611 : __DATE__ [2] == 'r' ? (__DATE__ [0] == 'M' ? 3 : 4) \
612 : __DATE__ [2] == 'y' ? 5 \
613 : __DATE__ [2] == 'l' ? 7 \
614 : __DATE__ [2] == 'g' ? 8 \
615 : __DATE__ [2] == 'p' ? 9 \
616 : __DATE__ [2] == 't' ? 10 \
617 : __DATE__ [2] == 'v' ? 11 : 12)
619 #define DAY ((__DATE__ [4] == ' ' ? 0 : __DATE__ [4] - '0') * 10 \
620 + (__DATE__ [5] - '0'))
622 #define DATE_AS_INT (((YEAR - 2000) * 12 + MONTH) * 31 + DAY)
624 CTime
compiletime(YEAR
, MONTH
, DAY
, 0, 0, 0);
625 CTime now
= CTime::GetCurrentTime();
627 CTimeSpan timediff
= now
-compiletime
;
628 if (timediff
.GetDays() > 3*31)
630 // crasher.Enable(FALSE);
634 void CTortoiseProcApp::InitializeJumpList()
636 // for Win7 : use a custom jump list
639 DeleteJumpList(APPID
);
640 DoInitializeJumpList();
644 void CTortoiseProcApp::DoInitializeJumpList()
646 ATL::CComPtr
<ICustomDestinationList
> pcdl
;
647 HRESULT hr
= pcdl
.CoCreateInstance(CLSID_DestinationList
, NULL
, CLSCTX_INPROC_SERVER
);
651 hr
= pcdl
->SetAppID(APPID
);
656 ATL::CComPtr
<IObjectArray
> poaRemoved
;
657 hr
= pcdl
->BeginList(&uMaxSlots
, IID_PPV_ARGS(&poaRemoved
));
661 ATL::CComPtr
<IObjectCollection
> poc
;
662 hr
= poc
.CoCreateInstance(CLSID_EnumerableObjectCollection
, NULL
, CLSCTX_INPROC_SERVER
);
666 CString sTemp
= CString(MAKEINTRESOURCE(IDS_MENUSETTINGS
));
669 ATL::CComPtr
<IShellLink
> psl
;
670 hr
= CreateShellLink(_T("/command:settings"), (LPCTSTR
)sTemp
, 20, &psl
);
674 sTemp
= CString(MAKEINTRESOURCE(IDS_MENUHELP
));
676 psl
.Release(); // Need to release the object before calling operator&()
677 hr
= CreateShellLink(_T("/command:help"), (LPCTSTR
)sTemp
, 19, &psl
);
682 ATL::CComPtr
<IObjectArray
> poa
;
683 hr
= poc
.QueryInterface(&poa
);
685 pcdl
->AppendCategory((LPCTSTR
)CString(MAKEINTRESOURCE(IDS_PROC_TASKS
)), poa
);
690 int CTortoiseProcApp::ExitInstance()
692 Gdiplus::GdiplusShutdown(m_gdiplusToken
);
694 CWinAppEx::ExitInstance();
700 void CTortoiseProcApp::CheckForNewerVersion()
702 // check for newer versions
703 if (CRegDWORD(_T("Software\\TortoiseGit\\VersionCheck"), TRUE
) != FALSE
)
709 if ((now
!= 0) && (localtime_s(&ptm
, &now
)==0))
712 // we don't calculate the real 'week of the year' here
713 // because just to decide if we should check for an update
714 // that's not needed.
715 week
= ptm
.tm_yday
/ 7;
717 CRegDWORD oldweek
= CRegDWORD(_T("Software\\TortoiseGit\\CheckNewerWeek"), (DWORD
)-1);
718 if (((DWORD
)oldweek
) == -1)
719 oldweek
= week
; // first start of TortoiseProc, no update check needed
722 if ((DWORD
)week
!= oldweek
)
726 TCHAR com
[MAX_PATH
+100];
727 GetModuleFileName(NULL
, com
, MAX_PATH
);
728 _tcscat_s(com
, MAX_PATH
+100, _T(" /command:updatecheck"));
730 CAppUtils::LaunchApplication(com
, 0, false);