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 "DirFileEnum.h"
31 #include "GitAdminDir.h"
33 #include "SmartHandle.h"
34 #include "Commands\Command.h"
35 #include "..\version.h"
36 #include "JumpListHelpers.h"
37 #include "SinglePropSheetDlg.h"
38 #include "Settings\setmainpage.h"
39 #include "Libraries.h"
40 #include "TaskbarUUID.h"
41 #include "GitConfig.h"
42 #include "SoundUtils.h"
44 #define STRUCT_IOVEC_DEFINED
50 #pragma comment(linker, "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
52 BEGIN_MESSAGE_MAP(CTortoiseProcApp
, CWinAppEx
)
53 ON_COMMAND(ID_HELP
, CWinAppEx::OnHelp
)
57 //CString CGit::m_MsysGitPath;
58 //////////////////////////////////////////////////////////////////////////
60 CTortoiseProcApp::CTortoiseProcApp()
63 // prevent from inheriting %GIT_DIR% from parent process by resetting it,
64 // use MSVC function instead of Windows API because MSVC runtime caches environment variables
65 _tputenv(_T("GIT_DIR="));
66 CCrashReport::Instance().AddUserInfoToReport(L
"CommandLine", GetCommandLine());
70 m_bLoadUserToolbars
= FALSE
;
73 m_gdiplusToken
= NULL
;
76 CTortoiseProcApp::~CTortoiseProcApp()
79 SYS_IMAGE_LIST().Cleanup();
82 // The one and only CTortoiseProcApp object
83 CTortoiseProcApp theApp
;
85 CString g_sGroupingUUID
;
88 #if ENABLE_CRASHHANLDER
89 CCrashReportTGit
crasher(L
"TortoiseGit " _T(APP_X64_STRING
), TGIT_VERMAJOR
, TGIT_VERMINOR
, TGIT_VERMICRO
, TGIT_VERBUILD
, TGIT_VERDATE
);
92 // CTortoiseProcApp initialization
94 BOOL
CTortoiseProcApp::InitInstance()
97 CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows
));
98 CMFCButton::EnableWindowsTheming();
100 Gdiplus::GdiplusStartupInput gdiplusStartupInput
;
101 Gdiplus::GdiplusStartup(&m_gdiplusToken
,&gdiplusStartupInput
,NULL
);
103 //set the resource dll for the required language
104 CRegDWORD loc
= CRegDWORD(_T("Software\\TortoiseGit\\LanguageID"), 1033);
108 langStr
.Format(_T("%d"), langId
);
109 CCrashReport::Instance().AddUserInfoToReport(L
"LanguageID", langStr
);
112 CStringA langpath
= CStringA(CPathUtils::GetAppParentDirectory());
113 langpath
+= "Languages";
114 HINSTANCE hInst
= NULL
;
117 langDll
.Format(_T("%sLanguages\\TortoiseProc%d.dll"), (LPCTSTR
)CPathUtils::GetAppParentDirectory(), langId
);
119 hInst
= LoadLibrary(langDll
);
121 CString sVer
= _T(STRPRODUCTVER
);
122 CString sFileVer
= CPathUtils::GetVersionFromFile(langDll
);
123 if (sFileVer
.Compare(sVer
)!=0)
130 AfxSetResourceHandle(hInst
);
134 DWORD lid
= SUBLANGID(langId
);
138 langId
= MAKELANGID(PRIMARYLANGID(langId
), lid
);
143 } while ((hInst
== NULL
) && (langId
!= 0));
145 _tcscpy_s(buf
, _T("en"));
147 // MFC uses a help file with the same name as the application by default,
148 // which means we have to change that default to our language specific help files
149 CString sHelppath
= CPathUtils::GetAppDirectory() + _T("TortoiseGit_en.chm");
150 free((void*)m_pszHelpFilePath
);
151 m_pszHelpFilePath
=_tcsdup(sHelppath
);
152 sHelppath
= CPathUtils::GetAppParentDirectory() + _T("Languages\\TortoiseGit_en.chm");
155 CString sLang
= _T("_");
156 if (GetLocaleInfo(MAKELCID(langId
, SORT_DEFAULT
), LOCALE_SISO639LANGNAME
, buf
, _countof(buf
)))
159 sHelppath
.Replace(_T("_en"), sLang
);
160 if (PathFileExists(sHelppath
))
162 free((void*)m_pszHelpFilePath
);
163 m_pszHelpFilePath
=_tcsdup(sHelppath
);
167 sHelppath
.Replace(sLang
, _T("_en"));
168 if (GetLocaleInfo(MAKELCID(langId
, SORT_DEFAULT
), LOCALE_SISO3166CTRYNAME
, buf
, _countof(buf
)))
172 sHelppath
.Replace(_T("_en"), sLang
);
173 if (PathFileExists(sHelppath
))
175 free((void*)m_pszHelpFilePath
);
176 m_pszHelpFilePath
=_tcsdup(sHelppath
);
180 sHelppath
.Replace(sLang
, _T("_en"));
182 DWORD lid
= SUBLANGID(langId
);
186 langId
= MAKELANGID(PRIMARYLANGID(langId
), lid
);
191 setlocale(LC_ALL
, "");
193 if (!g_Git
.CheckMsysGitDir())
195 UINT ret
= CMessageBox::Show(NULL
, IDS_PROC_NOMSYSGIT
, IDS_APPNAME
, 3, IDI_HAND
, IDS_PROC_SETMSYSGITPATH
, IDS_PROC_GOTOMSYSGITWEBSITE
, IDS_ABORTBUTTON
);
198 ShellExecute(NULL
, NULL
, _T("http://code.google.com/p/msysgit/"), NULL
, NULL
, SW_SHOW
);
202 // open settings dialog
203 CSinglePropSheetDlg(CString(MAKEINTRESOURCE(IDS_PROC_SETTINGS_TITLE
)), new CSetMainPage(), this->GetMainWnd()).DoModal();
207 if (CAppUtils::GetMsysgitVersion() < 0x01070a00)
209 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
);
212 CMessageBox::RemoveRegistryKey(_T("OldMsysgitVersionWarning")); // only store answer if it is "Ignore"
213 ShellExecute(NULL
, NULL
, _T("http://code.google.com/p/msysgit/"), NULL
, NULL
, SW_SHOW
);
218 CMessageBox::RemoveRegistryKey(_T("OldMsysgitVersionWarning")); // only store answer if it is "Ignore"
224 CCrashReport::Instance().AddUserInfoToReport(L
"msysGitDir", CGit::ms_LastMsysGitDir
);
225 CString versionString
;
226 versionString
.Format(_T("%d"), CGit::ms_LastMsysGitVersion
);
227 CCrashReport::Instance().AddUserInfoToReport(L
"msysGitVersion", versionString
);
230 // InitCommonControls() is required on Windows XP if an application
231 // manifest specifies use of ComCtl32.dll version 6 or later to enable
232 // visual styles. Otherwise, any window creation will fail.
234 INITCOMMONCONTROLSEX used
= {
235 sizeof(INITCOMMONCONTROLSEX
),
236 ICC_ANIMATE_CLASS
| ICC_BAR_CLASSES
| ICC_COOL_CLASSES
| ICC_DATE_CLASSES
|
237 ICC_HOTKEY_CLASS
| ICC_INTERNET_CLASSES
| ICC_LISTVIEW_CLASSES
|
238 ICC_NATIVEFNTCTL_CLASS
| ICC_PAGESCROLLER_CLASS
| ICC_PROGRESS_CLASS
|
239 ICC_TAB_CLASSES
| ICC_TREEVIEW_CLASSES
| ICC_UPDOWN_CLASS
|
240 ICC_USEREX_CLASSES
| ICC_WIN95_CLASSES
242 InitCommonControlsEx(&used
);
244 AfxEnableControlContainer();
246 CWinAppEx::InitInstance();
247 SetRegistryKey(_T("TortoiseGit"));
248 AfxGetApp()->m_pszProfileName
= _tcsdup(_T("TortoiseProc")); // w/o this ResizableLib will store data under TortoiseGitProc which is not compatible with older versions
250 CCmdLineParser
parser(AfxGetApp()->m_lpCmdLine
);
253 CString sVal
= parser
.GetVal(_T("hwnd"));
255 hWndExplorer
= (HWND
)_ttoi64(sVal
);
257 while (GetParent(hWndExplorer
)!=NULL
)
258 hWndExplorer
= GetParent(hWndExplorer
);
259 if (!IsWindow(hWndExplorer
))
264 // if HKCU\Software\TortoiseGit\Debug is not 0, show our command line
266 if (CRegDWORD(_T("Software\\TortoiseGit\\Debug"), FALSE
)==TRUE
)
267 AfxMessageBox(AfxGetApp()->m_lpCmdLine
, MB_OK
| MB_ICONINFORMATION
);
269 if (parser
.HasKey(_T("urlhandler")))
271 CString url
= parser
.GetVal(_T("urlhandler"));
272 if (url
.Find(_T("github-windows://openRepo/")) == 0)
274 url
= url
.Mid(26); // 26 = "github-windows://openRepo/".GetLength()
275 int questioMark
= url
.Find('?');
277 url
= url
.Left(questioMark
);
279 else if (url
.Find(_T("smartgit://cloneRepo/")) == 0)
281 url
= url
.Mid(21); // 21 = "smartgit://cloneRepo/".GetLength()
285 CMessageBox::Show(NULL
, IDS_ERR_INVALIDPATH
, IDS_APPNAME
, MB_ICONERROR
);
289 newCmd
.Format(_T("/command:clone /url:\"%s\""), url
);
290 parser
= CCmdLineParser(newCmd
);
293 if ( parser
.HasKey(_T("path")) && parser
.HasKey(_T("pathfile")))
295 CMessageBox::Show(NULL
, IDS_ERR_INVALIDPATH
, IDS_APPNAME
, MB_ICONERROR
);
299 CTGitPath cmdLinePath
;
300 CTGitPathList pathList
;
301 if (g_sGroupingUUID
.IsEmpty())
302 g_sGroupingUUID
= parser
.GetVal(L
"groupuuid");
303 if ( parser
.HasKey(_T("pathfile")) )
306 CString sPathfileArgument
= CPathUtils::GetLongPathname(parser
.GetVal(_T("pathfile")));
308 cmdLinePath
.SetFromUnknown(sPathfileArgument
);
309 if (pathList
.LoadFromFile(cmdLinePath
)==false)
310 return FALSE
; // no path specified!
311 if ( parser
.HasKey(_T("deletepathfile")) )
313 // We can delete the temporary path file, now that we've loaded it
314 ::DeleteFile(cmdLinePath
.GetWinPath());
316 // This was a path to a temporary file - it's got no meaning now, and
317 // anybody who uses it again is in for a problem...
324 CString sPathArgument
= CPathUtils::GetLongPathname(parser
.GetVal(_T("path")));
325 if (parser
.HasKey(_T("expaths")))
327 // an /expaths param means we're started via the buttons in our Win7 library
328 // and that means the value of /expaths is the current directory, and
329 // the selected paths are then added as additional parameters but without a key, only a value
331 // because of the "strange treatment of quotation marks and backslashes by CommandLineToArgvW"
332 // we have to escape the backslashes first. Since we're only dealing with paths here, that's
334 // Without this, a command line like:
335 // /command:commit /expaths:"D:\" "D:\Utils"
336 // would fail because the "D:\" is treated as the backslash being the escape char for the quotation
337 // mark and we'd end up with:
338 // argv[1] = /command:commit
339 // argv[2] = /expaths:D:" D:\Utils
340 // See here for more details: http://blogs.msdn.com/b/oldnewthing/archive/2010/09/17/10063629.aspx
341 CString cmdLine
= GetCommandLineW();
342 cmdLine
.Replace(L
"\\", L
"\\\\");
344 LPWSTR
*szArglist
= CommandLineToArgvW(cmdLine
, &nArgs
);
347 // argument 0 is the process path, so start with 1
348 for (int i
= 1; i
< nArgs
; ++i
)
350 if (szArglist
[i
][0] != '/')
352 if (!sPathArgument
.IsEmpty())
353 sPathArgument
+= '*';
354 sPathArgument
+= szArglist
[i
];
357 sPathArgument
.Replace(L
"\\\\", L
"\\");
359 LocalFree(szArglist
);
361 if (sPathArgument
.IsEmpty() && parser
.HasKey(L
"path"))
363 CMessageBox::Show(hWndExplorer
, IDS_ERR_INVALIDPATH
, IDS_APPNAME
, MB_ICONERROR
);
366 int asterisk
= sPathArgument
.Find('*');
367 cmdLinePath
.SetFromUnknown(asterisk
>= 0 ? sPathArgument
.Left(asterisk
) : sPathArgument
);
368 pathList
.LoadFromAsteriskSeparatedString(sPathArgument
);
371 if (pathList
.GetCount() == 0) {
372 pathList
.AddPath(CTGitPath::CTGitPath(g_Git
.m_CurrentDir
));
375 // Subversion sometimes writes temp files to the current directory!
376 // Since TSVN doesn't need a specific CWD anyway, we just set it
377 // to the users temp folder: that way, Subversion is guaranteed to
378 // have write access to the CWD
380 DWORD len
= GetCurrentDirectory(0, NULL
);
383 std::unique_ptr
<TCHAR
[]> originalCurrentDirectory(new TCHAR
[len
]);
384 if (GetCurrentDirectory(len
, originalCurrentDirectory
.get()))
386 sOrigCWD
= originalCurrentDirectory
.get();
387 sOrigCWD
= CPathUtils::GetLongPathname(sOrigCWD
);
390 TCHAR pathbuf
[MAX_PATH
];
391 GetTortoiseGitTempPath(MAX_PATH
, pathbuf
);
392 SetCurrentDirectory(pathbuf
);
395 CheckForNewerVersion();
397 CAutoGeneralHandle TGitMutex
= ::CreateMutex(NULL
, FALSE
, _T("TortoiseGitProc.exe"));
398 if (!g_Git
.SetCurrentDir(cmdLinePath
.GetWinPathString(), parser
.HasKey(_T("submodule")) == TRUE
))
400 for (int i
= 0; i
< pathList
.GetCount(); ++i
)
401 if(g_Git
.SetCurrentDir(pathList
[i
].GetWinPath()))
405 if(!g_Git
.m_CurrentDir
.IsEmpty())
407 sOrigCWD
= g_Git
.m_CurrentDir
;
408 SetCurrentDirectory(g_Git
.m_CurrentDir
);
411 if (g_sGroupingUUID
.IsEmpty())
413 CRegStdDWORD groupSetting
= CRegStdDWORD(_T("Software\\TortoiseGit\\GroupTaskbarIconsPerRepo"), 3);
414 switch (DWORD(groupSetting
))
418 // implemented differently to TortoiseSVN atm
424 if (g_GitAdminDir
.HasAdminDir(g_Git
.m_CurrentDir
, true, &wcroot
))
427 CStringA
wcRootA(wcroot
+ CPathUtils::GetAppDirectory());
428 if (!git_odb_hash(&oid
, wcRootA
.GetBuffer(), wcRootA
.GetLength(), GIT_OBJ_BLOB
))
431 git_oid_tostr(hash
.GetBufferSetLength(GIT_OID_HEXSZ
+ 1), GIT_OID_HEXSZ
+ 1, &oid
);
432 hash
.ReleaseBuffer();
433 g_sGroupingUUID
= hash
;
440 CString sAppID
= GetTaskIDPerUUID(g_sGroupingUUID
).c_str();
441 InitializeJumpList(sAppID
);
442 EnsureGitLibrary(false);
448 // requires CWD to be set
449 CGit::m_LogEncode
= CAppUtils::GetLogOutputEncode();
451 // make sure all config files are read in order to check that none contains an error
452 g_Git
.GetConfigValue(_T("doesnot.exist"));
461 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
)));
464 // open the config file with alternative editor
465 CAppUtils::LaunchAlternativeEditor(g_Git
.GetGitLocalConfig());
467 else if (choice
== 2)
469 // open the global config file with alternative editor
470 CAppUtils::LaunchAlternativeEditor(g_Git
.GetGitGlobalConfig());
476 // execute the requested command
477 CommandServer server
;
478 Command
* cmd
= server
.GetCommand(parser
.GetVal(_T("command")));
481 cmd
->SetExplorerHwnd(hWndExplorer
);
483 cmd
->SetParser(parser
);
484 cmd
->SetPaths(pathList
, cmdLinePath
);
486 retSuccess
= cmd
->Execute();
490 // Look for temporary files left around by TortoiseSVN and
491 // remove them. But only delete 'old' files because some
492 // apps might still be needing the recent ones.
494 DWORD len
= GetTortoiseGitTempPath(0, NULL
);
495 std::unique_ptr
<TCHAR
[]> path(new TCHAR
[len
+ 100]);
496 len
= GetTortoiseGitTempPath (len
+ 100, path
.get());
499 CDirFileEnum
finder(path
.get());
501 ::GetSystemTimeAsFileTime(&systime_
);
502 __int64 systime
= (((_int64
)systime_
.dwHighDateTime
)<<32) | ((__int64
)systime_
.dwLowDateTime
);
505 while (finder
.NextFile(filepath
, &isDir
))
507 HANDLE hFile
= ::CreateFile(filepath
, GENERIC_READ
, FILE_SHARE_READ
, NULL
, OPEN_EXISTING
, isDir
? FILE_FLAG_BACKUP_SEMANTICS
: NULL
, NULL
);
508 if (hFile
!= INVALID_HANDLE_VALUE
)
510 FILETIME createtime_
;
511 if (::GetFileTime(hFile
, &createtime_
, NULL
, NULL
))
513 ::CloseHandle(hFile
);
514 __int64 createtime
= (((_int64
)createtime_
.dwHighDateTime
)<<32) | ((__int64
)createtime_
.dwLowDateTime
);
515 if ((createtime
+ 864000000000) < systime
) //only delete files older than a day
517 ::SetFileAttributes(filepath
, FILE_ATTRIBUTE_NORMAL
);
519 ::RemoveDirectory(filepath
);
521 ::DeleteFile(filepath
);
525 ::CloseHandle(hFile
);
531 // Since the dialog has been closed, return FALSE so that we exit the
532 // application, rather than start the application's message pump.
536 void CTortoiseProcApp::CheckUpgrade()
538 CRegString regVersion
= CRegString(_T("Software\\TortoiseGit\\CurrentVersion"));
539 CString sVersion
= regVersion
;
540 if (sVersion
.Compare(_T(STRPRODUCTVER
))==0)
542 // we're starting the first time with a new version!
545 int pos
= sVersion
.Find('.');
548 lVersion
= (_ttol(sVersion
.Left(pos
))<<24);
549 lVersion
|= (_ttol(sVersion
.Mid(pos
+1))<<16);
550 pos
= sVersion
.Find('.', pos
+1);
551 lVersion
|= (_ttol(sVersion
.Mid(pos
+1))<<8);
555 pos
= sVersion
.Find(',');
558 lVersion
= (_ttol(sVersion
.Left(pos
))<<24);
559 lVersion
|= (_ttol(sVersion
.Mid(pos
+1))<<16);
560 pos
= sVersion
.Find(',', pos
+1);
561 lVersion
|= (_ttol(sVersion
.Mid(pos
+1))<<8);
565 if (lVersion
<= 0x01080401)
567 if (CRegStdDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\SendMail\\UseMAPI"), FALSE
) == TRUE
)
568 CRegStdDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\SendMail\\DeliveryType")) = 1;
569 CRegStdDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\SendMail\\UseMAPI")).removeValue();
572 if (lVersion
<= 0x01080202)
574 CSoundUtils::RegisterTGitSounds();
575 // upgrade to 1.8.3: force recreation of all diff scripts.
576 CAppUtils::SetupDiffScripts(true, CString());
579 if (lVersion
<= 0x01080100)
581 if (CRegStdDWORD(_T("Software\\TortoiseGit\\LogTopoOrder"), TRUE
) == FALSE
)
582 CRegStdDWORD(_T("Software\\TortoiseGit\\LogOrderBy")) = 0;
584 // smoothly migrate broken msysgit path settings
585 CString oldmsysGitSetting
= CRegString(REG_MSYSGIT_PATH
);
586 oldmsysGitSetting
.TrimRight(_T("\\"));
587 CString right
= oldmsysGitSetting
.Right(4);
588 if (oldmsysGitSetting
.GetLength() > 4 && oldmsysGitSetting
.Right(4) == _T("\\cmd"))
590 CString newPath
= oldmsysGitSetting
.Mid(0, oldmsysGitSetting
.GetLength() - 3) + _T("bin");
591 if (PathFileExists(newPath
+ _T("\\git.exe")))
593 CRegString(REG_MSYSGIT_PATH
) = newPath
;
594 g_Git
.m_bInitialized
= FALSE
;
595 g_Git
.CheckMsysGitDir();
600 if (lVersion
<= 0x01040000)
602 CRegStdDWORD(_T("Software\\TortoiseGit\\OwnerdrawnMenus")).removeValue();
605 if (lVersion
<= 0x01070600)
610 CRegStdDWORD(_T("Software\\TortoiseGit\\ConvertBase")).removeValue();
611 CRegStdDWORD(_T("Software\\TortoiseGit\\DiffProps")).removeValue();
612 if (CRegStdDWORD(_T("Software\\TortoiseGit\\CheckNewer"), TRUE
) == FALSE
)
613 CRegStdDWORD(_T("Software\\TortoiseGit\\VersionCheck")) = FALSE
;
616 if (lVersion
<= 0x01070E00)
618 CRegStdDWORD(_T("Software\\TortoiseGit\\CheckNewer")).removeValue();
620 CAppUtils::SetupDiffScripts(false, CString());
622 // set the current version so we don't come here again until the next update!
623 regVersion
= _T(STRPRODUCTVER
);
626 void CTortoiseProcApp::InitializeJumpList(const CString
& appid
)
628 // for Win7 : use a custom jump list
631 DeleteJumpList(appid
);
632 DoInitializeJumpList(appid
);
636 void CTortoiseProcApp::DoInitializeJumpList(const CString
& appid
)
638 ATL::CComPtr
<ICustomDestinationList
> pcdl
;
639 HRESULT hr
= pcdl
.CoCreateInstance(CLSID_DestinationList
, NULL
, CLSCTX_INPROC_SERVER
);
643 hr
= pcdl
->SetAppID(appid
);
648 ATL::CComPtr
<IObjectArray
> poaRemoved
;
649 hr
= pcdl
->BeginList(&uMaxSlots
, IID_PPV_ARGS(&poaRemoved
));
653 ATL::CComPtr
<IObjectCollection
> poc
;
654 hr
= poc
.CoCreateInstance(CLSID_EnumerableObjectCollection
, NULL
, CLSCTX_INPROC_SERVER
);
658 CString sTemp
= CString(MAKEINTRESOURCE(IDS_MENUSETTINGS
));
661 ATL::CComPtr
<IShellLink
> psl
;
662 hr
= CreateShellLink(_T("/command:settings"), (LPCTSTR
)sTemp
, 20, &psl
);
666 sTemp
= CString(MAKEINTRESOURCE(IDS_MENUHELP
));
668 psl
.Release(); // Need to release the object before calling operator&()
669 hr
= CreateShellLink(_T("/command:help"), (LPCTSTR
)sTemp
, 19, &psl
);
674 ATL::CComPtr
<IObjectArray
> poa
;
675 hr
= poc
.QueryInterface(&poa
);
677 pcdl
->AppendCategory((LPCTSTR
)CString(MAKEINTRESOURCE(IDS_PROC_TASKS
)), poa
);
682 int CTortoiseProcApp::ExitInstance()
684 Gdiplus::GdiplusShutdown(m_gdiplusToken
);
686 CWinAppEx::ExitInstance();
692 void CTortoiseProcApp::CheckForNewerVersion()
694 // check for newer versions
695 if (CRegDWORD(_T("Software\\TortoiseGit\\VersionCheck"), TRUE
) != FALSE
)
701 if ((now
!= 0) && (localtime_s(&ptm
, &now
)==0))
704 // Check daily for new preview releases
705 CRegDWORD oldday
= CRegDWORD(_T("Software\\TortoiseGit\\CheckNewerDay"), (DWORD
)-1);
706 if (((DWORD
)oldday
) == -1)
707 oldday
= ptm
.tm_yday
;
710 if ((DWORD
)oldday
!= (DWORD
)ptm
.tm_yday
)
712 oldday
= ptm
.tm_yday
;
715 // we don't calculate the real 'week of the year' here
716 // because just to decide if we should check for an update
717 // that's not needed.
718 week
= ptm
.tm_yday
/ 7;
720 CRegDWORD oldweek
= CRegDWORD(_T("Software\\TortoiseGit\\CheckNewerWeek"), (DWORD
)-1);
721 if (((DWORD
)oldweek
) == -1)
722 oldweek
= week
; // first start of TortoiseProc, no update check needed
725 if ((DWORD
)week
!= oldweek
)
729 CAppUtils::RunTortoiseGitProc(_T("/command:updatecheck"), false, false);