68326784ba4bd0e26ed2c126b7c0d4f205f87f29
[reactos.git] / dll / win32 / browseui / browseui.cpp
1 /*
2 * ReactOS Explorer
3 *
4 * Copyright 2009 Andrew Hill <ash77 at domain reactos.org>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library 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 GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21 #include "precomp.h"
22
23
24 HRESULT CAddressBand_CreateInstance(REFIID riid, void **ppv)
25 {
26 #if USE_CUSTOM_ADDRESSBAND
27 return ShellObjectCreator<CAddressBand>(riid, ppv);
28 #else
29 return CoCreateInstance(CLSID_SH_AddressBand, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARG(IUnknown, toolsBar));
30 #endif
31 }
32
33 HRESULT CAddressEditBox_CreateInstance(REFIID riid, void **ppv)
34 {
35 #if USE_CUSTOM_ADDRESSEDITBOX
36 return ShellObjectCreator<CAddressEditBox>(riid, ppv);
37 #else
38 return CoCreateInstance(CLSID_AddressEditBox, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARG(riid, &ppv));
39 #endif
40 }
41
42 HRESULT CBandProxy_CreateInstance(REFIID riid, void **ppv)
43 {
44 #if USE_CUSTOM_BANDPROXY
45 return ShellObjectCreator<CBandProxy>(riid, ppv);
46 #else
47 return CoCreateInstance(CLSID_BandProxy, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARG(riid, &ppv));
48 #endif
49 }
50
51 HRESULT CBrandBand_CreateInstance(REFIID riid, void **ppv)
52 {
53 #if USE_CUSTOM_BRANDBAND
54 return ShellObjectCreator<CBrandBand>(riid, ppv);
55 #else
56 return CoCreateInstance(CLSID_BrandBand, NULL, CLSCTX_INPROC_SERVER, riid, ppv);
57 #endif
58 }
59
60 HRESULT CExplorerBand_CreateInstance(REFIID riid, LPVOID *ppv)
61 {
62 #if USE_CUSTOM_EXPLORERBAND
63 return ShellObjectCreator<CExplorerBand>(riid, ppv);
64 #else
65 return CoCreateInstance(CLSID_ExplorerBand, NULL, CLSCTX_INPROC_SERVER, riid, ppv);
66 #endif
67 }
68
69 HRESULT CInternetToolbar_CreateInstance(REFIID riid, void **ppv)
70 {
71 #if USE_CUSTOM_INTERNETTOOLBAR
72 return ShellObjectCreator<CInternetToolbar>(riid, ppv);
73 #else
74 return CoCreateInstance(CLSID_InternetToolbar, NULL, CLSCTX_INPROC_SERVER, riid, ppv);
75 #endif
76 }
77
78 typedef HRESULT(WINAPI * PMENUBAND_CREATEINSTANCE)(REFIID riid, void **ppv);
79 typedef HRESULT(WINAPI * PMERGEDFOLDER_CREATEINSTANCE)(REFIID riid, void **ppv);
80
81 HRESULT CMergedFolder_CreateInstance(REFIID riid, void **ppv)
82 {
83 #if USE_CUSTOM_MERGEDFOLDER
84 HMODULE hRShell = GetModuleHandle(L"rshell.dll");
85 if (!hRShell)
86 hRShell = LoadLibrary(L"rshell.dll");
87
88 if (hRShell)
89 {
90 PMERGEDFOLDER_CREATEINSTANCE pCMergedFolder_CreateInstance = (PMERGEDFOLDER_CREATEINSTANCE)
91 GetProcAddress(hRShell, "CMergedFolder_CreateInstance");
92
93 if (pCMergedFolder_CreateInstance)
94 {
95 return pCMergedFolder_CreateInstance(riid, ppv);
96 }
97 }
98 #endif
99 return CoCreateInstance(CLSID_MergedFolder, NULL, CLSCTX_INPROC_SERVER, riid, ppv);
100 }
101
102 HRESULT CMenuBand_CreateInstance(REFIID iid, LPVOID *ppv)
103 {
104 #if USE_CUSTOM_MENUBAND
105 HMODULE hRShell = GetModuleHandleW(L"rshell.dll");
106
107 if (!hRShell)
108 hRShell = LoadLibraryW(L"rshell.dll");
109
110 if (hRShell)
111 {
112 PMENUBAND_CREATEINSTANCE func = (PMENUBAND_CREATEINSTANCE) GetProcAddress(hRShell, "CMenuBand_CreateInstance");
113 if (func)
114 {
115 return func(iid , ppv);
116 }
117 }
118 #endif
119 return CoCreateInstance(CLSID_MenuBand, NULL, CLSCTX_INPROC_SERVER, iid, ppv);
120 }
121
122
123 class CBrowseUIModule : public CComModule
124 {
125 public:
126 };
127
128
129 BEGIN_OBJECT_MAP(ObjectMap)
130 OBJECT_ENTRY(CLSID_AutoComplete, CAutoComplete)
131 OBJECT_ENTRY(CLSID_ACLMulti, CACLMulti)
132 OBJECT_ENTRY(CLSID_ACListISF, CACListISF)
133 OBJECT_ENTRY(CLSID_SH_AddressBand, CAddressBand)
134 OBJECT_ENTRY(CLSID_AddressEditBox, CAddressEditBox)
135 OBJECT_ENTRY(CLSID_BandProxy, CBandProxy)
136 OBJECT_ENTRY(CLSID_RebarBandSite, CBandSite)
137 OBJECT_ENTRY(CLSID_BandSiteMenu, CBandSiteMenu)
138 OBJECT_ENTRY(CLSID_BrandBand, CBrandBand)
139 OBJECT_ENTRY(CLSID_CCommonBrowser, CCommonBrowser)
140 OBJECT_ENTRY(CLSID_GlobalFolderSettings, CGlobalFolderSettings)
141 OBJECT_ENTRY(CLSID_InternetToolbar, CInternetToolbar)
142 OBJECT_ENTRY(CLSID_CRegTreeOptions, CRegTreeOptions)
143 OBJECT_ENTRY(CLSID_ExplorerBand, CExplorerBand)
144 OBJECT_ENTRY(CLSID_ProgressDialog, CProgressDialog)
145 OBJECT_ENTRY(CLSID_ISFBand, CISFBand)
146 END_OBJECT_MAP()
147
148 CBrowseUIModule gModule;
149 CAtlWinModule gWinModule;
150
151 /*************************************************************************
152 * BROWSEUI DllMain
153 */
154 STDAPI_(BOOL) DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID fImpLoad)
155 {
156 TRACE("%p 0x%x %p\n", hInstance, dwReason, fImpLoad);
157
158 if (dwReason == DLL_PROCESS_ATTACH)
159 {
160 gModule.Init(ObjectMap, hInstance, NULL);
161 DisableThreadLibraryCalls (hInstance);
162 }
163 else if (dwReason == DLL_PROCESS_DETACH)
164 {
165 gModule.Term();
166 }
167 return TRUE;
168 }
169
170 /***********************************************************************
171 * DllCanUnloadNow (BROWSEUI.@)
172 */
173 STDAPI DllCanUnloadNow()
174 {
175 return gModule.DllCanUnloadNow();
176 }
177
178 /***********************************************************************
179 * DllGetClassObject (BROWSEUI.@)
180 */
181 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
182 {
183 return gModule.DllGetClassObject(rclsid, riid, ppv);
184 }
185
186 /***********************************************************************
187 * DllRegisterServer (BROWSEUI.@)
188 */
189 STDAPI DllRegisterServer()
190 {
191 return gModule.DllRegisterServer(FALSE);
192 }
193
194 /***********************************************************************
195 * DllUnregisterServer (BROWSEUI.@)
196 */
197 STDAPI DllUnregisterServer()
198 {
199 return gModule.DllUnregisterServer(FALSE);
200 }
201
202 /***********************************************************************
203 * DllGetVersion (BROWSEUI.@)
204 */
205 STDAPI DllGetVersion(DLLVERSIONINFO *info)
206 {
207 if (info->cbSize != sizeof(DLLVERSIONINFO)) FIXME("support DLLVERSIONINFO2\n");
208
209 /* this is what IE6 on Windows 98 reports */
210 info->dwMajorVersion = 6;
211 info->dwMinorVersion = 0;
212 info->dwBuildNumber = 2600;
213 info->dwPlatformID = DLLVER_PLATFORM_WINDOWS;
214
215 return NOERROR;
216 }