OSDN Git Service

Merge branch 'rel_0.3.x'
[tortoisegit/TortoiseGitJp.git] / src / TortoiseOverlays / TortoiseOverlays.cpp
1 // TortoiseOverlays - an overlay handler for Tortoise clients\r
2 // Copyright (C) 2007 - TortoiseSVN\r
3 #include "stdafx.h"\r
4 #include "ShellExt.h"\r
5 #include "Guids.h"\r
6 #include "ShellExtClassFactory.h"\r
7 \r
8 UINT                            g_cRefThisDll = 0;                              ///< reference count of this DLL.\r
9 HINSTANCE                       g_hmodThisDll = NULL;                   ///< handle to this DLL itself.\r
10 \r
11 \r
12 #pragma comment(linker, "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")\r
13 \r
14 extern "C" int APIENTRY\r
15 DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /* lpReserved */)\r
16 {\r
17 #ifdef _DEBUG\r
18         // if no debugger is present, then don't load the dll.\r
19         // this prevents other apps from loading the dll and locking\r
20         // it.\r
21 \r
22         if (!::IsDebuggerPresent())\r
23         {\r
24                 return FALSE;\r
25         }\r
26 #endif\r
27 \r
28     if (dwReason == DLL_PROCESS_ATTACH)\r
29     {\r
30         // Extension DLL one-time initialization\r
31         g_hmodThisDll = hInstance;\r
32     }\r
33     return 1;   // ok\r
34 }\r
35 \r
36 STDAPI DllCanUnloadNow(void)\r
37 {\r
38         return (g_cRefThisDll == 0 ? S_OK : S_FALSE);\r
39 }\r
40 \r
41 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppvOut)\r
42 {\r
43     *ppvOut = NULL;\r
44         \r
45     FileState state = FileStateInvalid;\r
46     if (IsEqualIID(rclsid, CLSID_Tortoise_NORMAL))\r
47         state = FileStateNormal;\r
48     else if (IsEqualIID(rclsid, CLSID_Tortoise_MODIFIED))\r
49         state = FileStateModified;\r
50     else if (IsEqualIID(rclsid, CLSID_Tortoise_CONFLICT))\r
51         state = FileStateConflict;\r
52         else if (IsEqualIID(rclsid, CLSID_Tortoise_DELETED))\r
53                 state = FileStateDeleted;\r
54         else if (IsEqualIID(rclsid, CLSID_Tortoise_READONLY))\r
55                 state = FileStateReadOnly;\r
56         else if (IsEqualIID(rclsid, CLSID_Tortoise_LOCKED))\r
57                 state = FileStateLocked;\r
58         else if (IsEqualIID(rclsid, CLSID_Tortoise_ADDED))\r
59                 state = FileStateAdded;\r
60         else if (IsEqualIID(rclsid, CLSID_Tortoise_IGNORED))\r
61                 state = FileStateIgnored;\r
62         else if (IsEqualIID(rclsid, CLSID_Tortoise_UNVERSIONED))\r
63                 state = FileStateUnversioned;\r
64         \r
65     if (state != FileStateInvalid)\r
66     {\r
67                 CShellExtClassFactory *pcf = new CShellExtClassFactory(state);\r
68                 return pcf->QueryInterface(riid, ppvOut);\r
69     }\r
70         \r
71     return CLASS_E_CLASSNOTAVAILABLE;\r
72 \r
73 }\r
74 \r
75 \r