OSDN Git Service

Add IBugTraqProvider
[tortoisegit/TortoiseGitJp.git] / src / TortoiseGitSetup / CustomActions / CustomActions.cpp
1 // TortoiseSVN - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2003-2008 - TortoiseSVN\r
4 \r
5 // This program is free software; you can redistribute it and/or\r
6 // modify it under the terms of the GNU General Public License\r
7 // as published by the Free Software Foundation; either version 2\r
8 // of the License, or (at your option) any later version.\r
9 \r
10 // This program is distributed in the hope that it will be useful,\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13 // GNU General Public License for more details.\r
14 \r
15 // You should have received a copy of the GNU General Public License\r
16 // along with this program; if not, write to the Free Software Foundation,\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
18 //\r
19 \r
20 \r
21 /* BIG FAT WARNING: Do not use any functions which require the C-Runtime library\r
22    in this custom action dll! The runtimes might not be installed yet!\r
23 */\r
24 \r
25 #include "stdafx.h"\r
26 #include "shlwapi.h"\r
27 #include "shellapi.h"\r
28 #pragma comment(lib, "shlwapi")\r
29 #pragma comment(lib, "shell32")\r
30 \r
31 #ifdef WIN64\r
32 #define TSVN_CACHE_WINDOW_NAME _T("TGitCacheWindow64")\r
33 #else\r
34 #define TSVN_CACHE_WINDOW_NAME _T("TGitCacheWindow")\r
35 #endif\r
36 \r
37 \r
38 BOOL APIENTRY DllMain( HANDLE hModule, \r
39                        DWORD  ul_reason_for_call, \r
40                        LPVOID lpReserved\r
41                                          )\r
42 {\r
43     return TRUE;\r
44 }\r
45 \r
46 UINT __stdcall TerminateCache(MSIHANDLE hModule)\r
47 {\r
48         HWND hWnd = FindWindow(TSVN_CACHE_WINDOW_NAME, TSVN_CACHE_WINDOW_NAME);\r
49         if (hWnd)\r
50         {\r
51                 PostMessage(hWnd, WM_CLOSE, NULL, NULL);\r
52                 for (int i=0; i<10; ++i)\r
53                 {\r
54                         Sleep(500);\r
55                         if (!IsWindow(hWnd))\r
56                         {\r
57                                 // Cache is gone!\r
58                                 return ERROR_SUCCESS;\r
59                         }\r
60                 }\r
61                 // Don't return ERROR_FUNCTION_FAILED, because even if the cache is still\r
62                 // running, the installer will overwrite the file, and we require a\r
63                 // reboot anyway after upgrading.\r
64                 return ERROR_SUCCESS;\r
65         }\r
66         // cache wasn't even running\r
67         return ERROR_SUCCESS;\r
68 }\r
69 \r
70 UINT __stdcall OpenDonatePage(MSIHANDLE hModule)\r
71 {\r
72         ShellExecute(NULL, _T("open"), _T("http://tortoisesvn.tigris.org/donate.html"), NULL,NULL, SW_SHOW);\r
73         return ERROR_SUCCESS;\r
74 }\r
75 \r
76 UINT __stdcall MsgBox(MSIHANDLE hModule)\r
77 {\r
78         MessageBox(NULL, _T("CustomAction \"MsgBox\" running"), _T("Installer"), MB_ICONINFORMATION);\r
79         return ERROR_SUCCESS;\r
80 }\r