Fixed issue #507: Help Spell error and push wrongly link to sync
[TortoiseGit.git] / src / TortoiseProc / TortoiseProc.cpp
blobade6dd5a92473fc5b5117775c7c1888ba5881675
1 // TortoiseSVN - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include "stdafx.h"
20 //#include "vld.h"
21 #include "TortoiseProc.h"
22 #include "SysImageList.h"
23 #include "CrashReport.h"
24 #include "CmdLineParser.h"
25 #include "Hooks.h"
26 #include "AppUtils.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 "SVN.h"
34 #include "GitAdminDir.h"
35 #include "Git.h"
36 //#include "SVNGlobal.h"
37 //#include "svn_types.h"
38 //#include "svn_dso.h"
39 //#include <openssl/ssl.h>
40 //#include <openssl/err.h>
42 #include "Commands\Command.h"
43 #include "CommonResource.h"
44 #include "..\version.h"
45 #include "..\Settings\Settings.h"
46 #include "gitindex.h"
48 #define STRUCT_IOVEC_DEFINED
49 //#include "sasl.h"
51 #ifdef _DEBUG
52 #define new DEBUG_NEW
53 #endif
55 #pragma comment(linker, "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
58 BEGIN_MESSAGE_MAP(CTortoiseProcApp, CWinAppEx)
59 ON_COMMAND(ID_HELP, CWinAppEx::OnHelp)
60 END_MESSAGE_MAP()
62 //CString g_version;
63 //CString CGit::m_MsysGitPath;
64 //////////////////////////////////////////////////////////////////////////
66 CTortoiseProcApp::CTortoiseProcApp()
68 EnableHtmlHelp();
69 // int argc = 0;
70 // g_version=_T("abc");
71 // const char* const * argv = NULL;
72 // apr_app_initialize(&argc, &argv, NULL);
73 // svn_dso_initialize2();
74 SYS_IMAGE_LIST();
75 // CHooks::Create();
76 g_GitAdminDir.Init();
77 m_bLoadUserToolbars = FALSE;
78 m_bSaveState = FALSE;
79 retSuccess = false;
80 //CGit git;
81 //git.GetUserName();
86 CTortoiseProcApp::~CTortoiseProcApp()
88 // sasl_done();
90 // global application exit cleanup (after all SSL activity is shutdown)
91 // we have to clean up SSL ourselves, since neon doesn't do that (can't do it)
92 // because those cleanup functions work globally per process.
93 //ERR_free_strings();
94 //EVP_cleanup();
95 //CRYPTO_cleanup_all_ex_data();
97 // since it is undefined *when* the global object SVNAdminDir is
98 // destroyed, we tell it to destroy the memory pools and terminate apr
99 // *now* instead of later when the object itself is destroyed.
100 g_GitAdminDir.Close();
101 // CHooks::Destroy();
102 SYS_IMAGE_LIST().Cleanup();
103 //apr_terminate();
106 // The one and only CTortoiseProcApp object
107 CTortoiseProcApp theApp;
108 HWND hWndExplorer;
110 BOOL CTortoiseProcApp::CheckMsysGitDir()
112 CGitIndexFileMap map;
113 //int status;
114 //CTGitPath path;
115 //path.SetFromGit(_T("src/gpl.txt"));
116 //map.GetFileStatus(_T("D:\\TortoiseGit"),&path, &status);
117 return g_Git.CheckMsysGitDir();
119 CCrashReport crasher("tortoisegit-bug@googlegroups.com", "Crash Report for TortoiseGit " APP_X64_STRING " : " STRPRODUCTVER, TRUE);// crash
121 // CTortoiseProcApp initialization
123 BOOL CTortoiseProcApp::InitInstance()
125 EnableCrashHandler();
126 CheckUpgrade();
127 CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));
128 CMFCButton::EnableWindowsTheming();
130 Gdiplus::GdiplusStartupInput gdiplusStartupInput;
131 Gdiplus::GdiplusStartup(&m_gdiplusToken,&gdiplusStartupInput,NULL);
133 if(!CheckMsysGitDir())
135 if(CMessageBox::Show(NULL,_T("MSysGit(http://code.google.com/p/msysgit) have not installed Correctly\n\
136 or MSysGit Path setting error\n\
137 Click Yes to open setting dialog to setup MSysGit Path"),
138 _T("TortoiseGit"),MB_YESNO|MB_ICONERROR)==IDYES)
140 // open settings dialog
141 CSettings dlg(IDS_PROC_SETTINGS_TITLE);
142 dlg.SetTreeViewMode(TRUE, TRUE, TRUE);
143 dlg.SetTreeWidth(220);
145 dlg.DoModal();
146 dlg.HandleRestart();
147 return TRUE;
149 return FALSE;
152 //set the resource dll for the required language
153 CRegDWORD loc = CRegDWORD(_T("Software\\TortoiseGit\\LanguageID"), 1033);
154 long langId = loc;
155 CString langDll;
156 CStringA langpath = CStringA(CPathUtils::GetAppParentDirectory());
157 langpath += "Languages";
158 // bindtextdomain("subversion", (LPCSTR)langpath);
159 // bind_textdomain_codeset("subversion", "UTF-8");
160 HINSTANCE hInst = NULL;
163 langDll.Format(_T("..\\Languages\\TortoiseProc%d.dll"), langId);
165 hInst = LoadLibrary(langDll);
167 CString sVer = _T(STRPRODUCTVER);
168 CString sFileVer = CPathUtils::GetVersionFromFile(langDll);
169 if (sFileVer.Compare(sVer)!=0)
171 FreeLibrary(hInst);
172 hInst = NULL;
174 if (hInst != NULL)
176 AfxSetResourceHandle(hInst);
178 else
180 DWORD lid = SUBLANGID(langId);
181 lid--;
182 if (lid > 0)
184 langId = MAKELANGID(PRIMARYLANGID(langId), lid);
186 else
187 langId = 0;
189 } while ((hInst == NULL) && (langId != 0));
190 TCHAR buf[6];
191 _tcscpy_s(buf, _T("en"));
192 langId = loc;
193 CString sHelppath;
194 sHelppath = this->m_pszHelpFilePath;
195 sHelppath = sHelppath.MakeLower();
196 // MFC uses a help file with the same name as the application by default,
197 // which means we have to change that default to our language specific help files
198 sHelppath.Replace(_T("tortoiseproc.chm"), _T("TortoiseGit_en.chm"));
199 free((void*)m_pszHelpFilePath);
200 m_pszHelpFilePath=_tcsdup(sHelppath);
201 sHelppath = CPathUtils::GetAppParentDirectory() + _T("Languages\\TortoiseGit_en.chm");
204 CString sLang = _T("_");
205 if (GetLocaleInfo(MAKELCID(langId, SORT_DEFAULT), LOCALE_SISO639LANGNAME, buf, sizeof(buf)))
207 sLang += buf;
208 sHelppath.Replace(_T("_en"), sLang);
209 if (PathFileExists(sHelppath))
211 free((void*)m_pszHelpFilePath);
212 m_pszHelpFilePath=_tcsdup(sHelppath);
213 break;
216 sHelppath.Replace(sLang, _T("_en"));
217 if (GetLocaleInfo(MAKELCID(langId, SORT_DEFAULT), LOCALE_SISO3166CTRYNAME, buf, sizeof(buf)))
219 sLang += _T("_");
220 sLang += buf;
221 sHelppath.Replace(_T("_en"), sLang);
222 if (PathFileExists(sHelppath))
224 free((void*)m_pszHelpFilePath);
225 m_pszHelpFilePath=_tcsdup(sHelppath);
226 break;
229 sHelppath.Replace(sLang, _T("_en"));
231 DWORD lid = SUBLANGID(langId);
232 lid--;
233 if (lid > 0)
235 langId = MAKELANGID(PRIMARYLANGID(langId), lid);
237 else
238 langId = 0;
239 } while (langId);
240 setlocale(LC_ALL, "");
242 // InitCommonControls() is required on Windows XP if an application
243 // manifest specifies use of ComCtl32.dll version 6 or later to enable
244 // visual styles. Otherwise, any window creation will fail.
246 INITCOMMONCONTROLSEX used = {
247 sizeof(INITCOMMONCONTROLSEX),
248 ICC_ANIMATE_CLASS | ICC_BAR_CLASSES | ICC_COOL_CLASSES | ICC_DATE_CLASSES |
249 ICC_HOTKEY_CLASS | ICC_INTERNET_CLASSES | ICC_LISTVIEW_CLASSES |
250 ICC_NATIVEFNTCTL_CLASS | ICC_PAGESCROLLER_CLASS | ICC_PROGRESS_CLASS |
251 ICC_TAB_CLASSES | ICC_TREEVIEW_CLASSES | ICC_UPDOWN_CLASS |
252 ICC_USEREX_CLASSES | ICC_WIN95_CLASSES
254 InitCommonControlsEx(&used);
255 AfxOleInit();
256 AfxEnableControlContainer();
257 AfxInitRichEdit2();
258 CWinAppEx::InitInstance();
259 SetRegistryKey(_T("TortoiseGit"));
261 CCmdLineParser parser(AfxGetApp()->m_lpCmdLine);
263 // if HKCU\Software\TortoiseSVN\Debug is not 0, show our command line
264 // in a message box
265 if (CRegDWORD(_T("Software\\TortoiseGit\\Debug"), FALSE)==TRUE)
266 AfxMessageBox(AfxGetApp()->m_lpCmdLine, MB_OK | MB_ICONINFORMATION);
268 if ( parser.HasKey(_T("path")) && parser.HasKey(_T("pathfile")))
270 CMessageBox::Show(NULL, IDS_ERR_INVALIDPATH, IDS_APPNAME, MB_ICONERROR);
271 return FALSE;
274 CTGitPath cmdLinePath;
275 CTGitPathList pathList;
276 if ( parser.HasKey(_T("pathfile")) )
279 CString sPathfileArgument = CPathUtils::GetLongPathname(parser.GetVal(_T("pathfile")));
281 cmdLinePath.SetFromUnknown(sPathfileArgument);
282 if (pathList.LoadFromFile(cmdLinePath)==false)
283 return FALSE; // no path specified!
284 if ( parser.HasKey(_T("deletepathfile")) )
286 // We can delete the temporary path file, now that we've loaded it
287 ::DeleteFile(cmdLinePath.GetWinPath());
289 // This was a path to a temporary file - it's got no meaning now, and
290 // anybody who uses it again is in for a problem...
291 cmdLinePath.Reset();
294 else
297 CString sPathArgument = CPathUtils::GetLongPathname(parser.GetVal(_T("path")));
298 int asterisk = sPathArgument.Find('*');
299 cmdLinePath.SetFromUnknown(asterisk >= 0 ? sPathArgument.Left(asterisk) : sPathArgument);
300 pathList.LoadFromAsteriskSeparatedString(sPathArgument);
304 hWndExplorer = NULL;
305 CString sVal = parser.GetVal(_T("hwnd"));
306 if (!sVal.IsEmpty())
307 hWndExplorer = (HWND)_ttoi64(sVal);
309 while (GetParent(hWndExplorer)!=NULL)
310 hWndExplorer = GetParent(hWndExplorer);
311 if (!IsWindow(hWndExplorer))
313 hWndExplorer = NULL;
316 // Subversion sometimes writes temp files to the current directory!
317 // Since TSVN doesn't need a specific CWD anyway, we just set it
318 // to the users temp folder: that way, Subversion is guaranteed to
319 // have write access to the CWD
321 DWORD len = GetCurrentDirectory(0, NULL);
322 if (len)
324 TCHAR * originalCurrentDirectory = new TCHAR[len];
325 if (GetCurrentDirectory(len, originalCurrentDirectory))
327 //sOrigCWD = originalCurrentDirectory;
328 //sOrigCWD = CPathUtils::GetLongPathname(sOrigCWD);
330 delete [] originalCurrentDirectory;
332 TCHAR pathbuf[MAX_PATH];
333 GetTempPath(MAX_PATH, pathbuf);
334 SetCurrentDirectory(pathbuf);
337 // check for newer versions
338 if (CRegDWORD(_T("Software\\TortoiseGit\\CheckNewer"), TRUE) != FALSE)
340 time_t now;
341 struct tm ptm;
343 time(&now);
344 if ((now != 0) && (localtime_s(&ptm, &now)==0))
346 int week = 0;
347 // we don't calculate the real 'week of the year' here
348 // because just to decide if we should check for an update
349 // that's not needed.
350 week = ptm.tm_yday / 7;
352 CRegDWORD oldweek = CRegDWORD(_T("Software\\TortoiseGit\\CheckNewerWeek"), (DWORD)-1);
353 if (((DWORD)oldweek) == -1)
354 oldweek = week; // first start of TortoiseProc, no update check needed
355 else
357 if ((DWORD)week != oldweek)
359 oldweek = week;
361 TCHAR com[MAX_PATH+100];
362 GetModuleFileName(NULL, com, MAX_PATH);
363 _tcscat_s(com, MAX_PATH+100, _T(" /command:updatecheck"));
365 CAppUtils::LaunchApplication(com, 0, false);
371 if (parser.HasVal(_T("configdir")))
373 // the user can override the location of the Subversion config directory here
374 CString sConfigDir = parser.GetVal(_T("configdir"));
375 // g_GitGlobal.SetConfigDir(sConfigDir);
377 // to avoid that SASL will look for and load its plugin dlls all around the
378 // system, we set the path here.
379 // Note that SASL doesn't have to be initialized yet for this to work
380 // sasl_set_path(SASL_PATH_TYPE_PLUGIN, (LPSTR)(LPCSTR)CUnicodeUtils::GetUTF8(CPathUtils::GetAppDirectory().TrimRight('\\')));
382 HANDLE TSVNMutex = ::CreateMutex(NULL, FALSE, _T("TortoiseGitProc.exe"));
384 #if 0
385 CString err = Git::CheckConfigFile();
386 if (!err.IsEmpty())
388 CMessageBox::Show(hWndExplorer, err, _T("TortoiseGit"), MB_ICONERROR);
389 // Normally, we give-up and exit at this point, but there is a trap here
390 // in that the user might need to use the settings dialog to edit the config file.
391 if (CString(parser.GetVal(_T("command"))).Compare(_T("settings"))==0)
393 // just open the config file
394 TCHAR buf[MAX_PATH];
395 SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, buf);
396 CString path = buf;
397 path += _T("\\Git\\config");
398 CAppUtils::StartTextViewer(path);
399 return FALSE;
402 #endif
405 // execute the requested command
406 CommandServer server;
407 Command * cmd = server.GetCommand(parser.GetVal(_T("command")));
408 if (cmd)
410 cmd->SetExplorerHwnd(hWndExplorer);
412 if(!g_Git.SetCurrentDir(cmdLinePath.GetWinPathString()))
414 int i=0;
415 for(i=0;i<pathList.GetCount();i++)
416 if(g_Git.SetCurrentDir(pathList[i].GetWinPath()))
417 break;
420 if(!g_Git.m_CurrentDir.IsEmpty())
421 SetCurrentDirectory(g_Git.m_CurrentDir);
423 cmd->SetParser(parser);
424 cmd->SetPaths(pathList, cmdLinePath);
426 CGit::m_LogEncode = CAppUtils::GetLogOutputEncode();
428 retSuccess = cmd->Execute();
429 delete cmd;
432 if (TSVNMutex)
433 ::CloseHandle(TSVNMutex);
435 // Look for temporary files left around by TortoiseSVN and
436 // remove them. But only delete 'old' files because some
437 // apps might still be needing the recent ones.
439 DWORD len = ::GetTempPath(0, NULL);
440 TCHAR * path = new TCHAR[len + 100];
441 len = ::GetTempPath (len+100, path);
442 if (len != 0)
444 CSimpleFileFind finder = CSimpleFileFind(path, _T("*svn*.*"));
445 FILETIME systime_;
446 ::GetSystemTimeAsFileTime(&systime_);
447 __int64 systime = (((_int64)systime_.dwHighDateTime)<<32) | ((__int64)systime_.dwLowDateTime);
448 while (finder.FindNextFileNoDirectories())
450 CString filepath = finder.GetFilePath();
451 HANDLE hFile = ::CreateFile(filepath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, NULL, NULL);
452 if (hFile != INVALID_HANDLE_VALUE)
454 FILETIME createtime_;
455 if (::GetFileTime(hFile, &createtime_, NULL, NULL))
457 ::CloseHandle(hFile);
458 __int64 createtime = (((_int64)createtime_.dwHighDateTime)<<32) | ((__int64)createtime_.dwLowDateTime);
459 if ((createtime + 864000000000) < systime) //only delete files older than a day
461 ::SetFileAttributes(filepath, FILE_ATTRIBUTE_NORMAL);
462 ::DeleteFile(filepath);
465 else
466 ::CloseHandle(hFile);
470 delete[] path;
474 // Since the dialog has been closed, return FALSE so that we exit the
475 // application, rather than start the application's message pump.
476 return FALSE;
481 void CTortoiseProcApp::CheckUpgrade()
483 CRegString regVersion = CRegString(_T("Software\\TortoiseGit\\CurrentVersion"));
484 CString sVersion = regVersion;
485 if (sVersion.Compare(_T(STRPRODUCTVER))==0)
486 return;
487 // we're starting the first time with a new version!
489 LONG lVersion = 0;
490 int pos = sVersion.Find(',');
491 if (pos > 0)
493 lVersion = (_ttol(sVersion.Left(pos))<<24);
494 lVersion |= (_ttol(sVersion.Mid(pos+1))<<16);
495 pos = sVersion.Find(',', pos+1);
496 lVersion |= (_ttol(sVersion.Mid(pos+1))<<8);
499 CRegDWORD regval = CRegDWORD(_T("Software\\TortoiseGit\\DontConvertBase"), 999);
500 if ((DWORD)regval != 999)
502 // there's a leftover registry setting we have to convert and then delete it
503 CRegDWORD newregval = CRegDWORD(_T("Software\\TortoiseGit\\ConvertBase"));
504 newregval = !regval;
505 regval.removeValue();
507 #if 0
508 if (lVersion <= 0x01010300)
510 CSoundUtils::RegisterTSVNSounds();
511 // remove all saved dialog positions
512 CRegString(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\")).removeKey();
513 CRegDWORD(_T("Software\\TortoiseGit\\RecursiveOverlay")).removeValue();
514 // remove the external cache key
515 CRegDWORD(_T("Software\\TortoiseGit\\ExternalCache")).removeValue();
517 #endif
518 if (lVersion <= 0x01020200)
520 // upgrade to > 1.2.3 means the doc diff scripts changed from vbs to js
521 // so remove the diff/merge scripts if they're the defaults
522 CRegString diffreg = CRegString(_T("Software\\TortoiseGit\\DiffTools\\.doc"));
523 CString sDiff = diffreg;
524 CString sCL = _T("wscript.exe \"") + CPathUtils::GetAppParentDirectory()+_T("Diff-Scripts\\diff-doc.vbs\"");
525 if (sDiff.Left(sCL.GetLength()).CompareNoCase(sCL)==0)
526 diffreg = _T("");
527 CRegString mergereg = CRegString(_T("Software\\TortoiseGit\\MergeTools\\.doc"));
528 sDiff = mergereg;
529 sCL = _T("wscript.exe \"") + CPathUtils::GetAppParentDirectory()+_T("Diff-Scripts\\merge-doc.vbs\"");
530 if (sDiff.Left(sCL.GetLength()).CompareNoCase(sCL)==0)
531 mergereg = _T("");
533 if (lVersion <= 0x01040000)
535 CRegStdWORD(_T("Software\\TortoiseGit\\OwnerdrawnMenus")).removeValue();
538 // set the custom diff scripts for every user
539 CString scriptsdir = CPathUtils::GetAppParentDirectory();
540 scriptsdir += _T("Diff-Scripts");
541 CSimpleFileFind files(scriptsdir);
542 while (files.FindNextFileNoDirectories())
544 CString file = files.GetFilePath();
545 CString filename = files.GetFileName();
546 CString ext = file.Mid(file.ReverseFind('-')+1);
547 ext = _T(".")+ext.Left(ext.ReverseFind('.'));
548 CString kind;
549 if (file.Right(3).CompareNoCase(_T("vbs"))==0)
551 kind = _T(" //E:vbscript");
553 if (file.Right(2).CompareNoCase(_T("js"))==0)
555 kind = _T(" //E:javascript");
558 if (filename.Left(5).CompareNoCase(_T("diff-"))==0)
560 CRegString diffreg = CRegString(_T("Software\\TortoiseGit\\DiffTools\\")+ext);
561 CString diffregstring = diffreg;
562 if ((diffregstring.IsEmpty()) || (diffregstring.Find(filename)>=0))
563 diffreg = _T("wscript.exe \"") + file + _T("\" %base %mine") + kind;
565 if (filename.Left(6).CompareNoCase(_T("merge-"))==0)
567 CRegString diffreg = CRegString(_T("Software\\TortoiseGit\\MergeTools\\")+ext);
568 CString diffregstring = diffreg;
569 if ((diffregstring.IsEmpty()) || (diffregstring.Find(filename)>=0))
570 diffreg = _T("wscript.exe \"") + file + _T("\" %merged %theirs %mine %base") + kind;
574 // Initialize "Software\\TortoiseGit\\DiffProps" once with the same value as "Software\\TortoiseGit\\Diff"
575 CRegString regDiffPropsPath = CRegString(_T("Software\\TortoiseGit\\DiffProps"),_T("non-existant"));
576 CString strDiffPropsPath = regDiffPropsPath;
577 if ( strDiffPropsPath==_T("non-existant") )
579 CString strDiffPath = CRegString(_T("Software\\TortoiseGit\\Diff"));
580 regDiffPropsPath = strDiffPath;
583 // set the current version so we don't come here again until the next update!
584 regVersion = _T(STRPRODUCTVER);
587 void CTortoiseProcApp::EnableCrashHandler()
589 // the crash handler is enabled by default, but we disable it
590 // after 3 months after a release
592 #define YEAR ((((__DATE__ [7] - '0') * 10 + (__DATE__ [8] - '0')) * 10 \
593 + (__DATE__ [9] - '0')) * 10 + (__DATE__ [10] - '0'))
595 #define MONTH (__DATE__ [2] == 'n' ? (__DATE__ [1] == 'a' ? 1 : 6) \
596 : __DATE__ [2] == 'b' ? 2 \
597 : __DATE__ [2] == 'r' ? (__DATE__ [0] == 'M' ? 3 : 4) \
598 : __DATE__ [2] == 'y' ? 5 \
599 : __DATE__ [2] == 'l' ? 7 \
600 : __DATE__ [2] == 'g' ? 8 \
601 : __DATE__ [2] == 'p' ? 9 \
602 : __DATE__ [2] == 't' ? 10 \
603 : __DATE__ [2] == 'v' ? 11 : 12)
605 #define DAY ((__DATE__ [4] == ' ' ? 0 : __DATE__ [4] - '0') * 10 \
606 + (__DATE__ [5] - '0'))
608 #define DATE_AS_INT (((YEAR - 2000) * 12 + MONTH) * 31 + DAY)
610 CTime compiletime(YEAR, MONTH, DAY, 0, 0, 0);
611 CTime now = CTime::GetCurrentTime();
613 CTimeSpan timediff = now-compiletime;
614 if (timediff.GetDays() > 3*31)
616 // crasher.Enable(FALSE);
620 int CTortoiseProcApp::ExitInstance()
622 Gdiplus::GdiplusShutdown(m_gdiplusToken);
624 CWinAppEx::ExitInstance();
625 if (retSuccess)
626 return 0;
627 return -1;