[EXPLORER] -If rshell is present and CBandSiteMenu_CreateInstance or CBandSite_Create...
[reactos.git] / reactos / base / shell / explorer / rshell.cpp
1 /*
2 * ReactOS Explorer
3 *
4 * Copyright 2014 Giannis Adamopoulos
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #include "precomp.h"
22
23 static HINSTANCE ghRShell = NULL;
24
25 typedef HRESULT(WINAPI * PSTARTMENU_CONSTRUCTOR)(REFIID riid, void **ppv);
26
27 VOID InitRSHELL(VOID)
28 {
29 ghRShell = LoadLibraryW(L"rshell.dll");
30 }
31
32 HRESULT WINAPI _CStartMenu_Constructor(REFIID riid, void **ppv)
33 {
34 if (ghRShell)
35 {
36 PSTARTMENU_CONSTRUCTOR func = (PSTARTMENU_CONSTRUCTOR)GetProcAddress(ghRShell, "CStartMenu_Constructor");
37 if (func)
38 {
39 return func(riid, ppv);
40 }
41 }
42
43 return CoCreateInstance(CLSID_StartMenu,
44 NULL,
45 CLSCTX_INPROC_SERVER,
46 riid,
47 ppv);
48 }
49
50 typedef HANDLE(WINAPI * PSHCREATEDESKTOP)(IShellDesktopTray *ShellDesk);
51
52 HANDLE WINAPI _SHCreateDesktop(IShellDesktopTray *ShellDesk)
53 {
54 HINSTANCE hFallback;
55
56 if (ghRShell)
57 {
58 PSHCREATEDESKTOP func = (PSHCREATEDESKTOP)GetProcAddress(ghRShell, "SHCreateDesktop");
59 if (func)
60 {
61 return func(ShellDesk);
62 }
63 }
64
65 hFallback = GetModuleHandleW(L"shell32.dll");
66
67 if (hFallback)
68 {
69 PSHCREATEDESKTOP func = (PSHCREATEDESKTOP) GetProcAddress(hFallback, (LPCSTR) 200);
70 if (func)
71 {
72 return func(ShellDesk);
73 }
74 }
75
76 return 0;
77 }
78
79 typedef BOOL(WINAPI *PSHDESKTOPMESSAGELOOP)(HANDLE hDesktop);
80
81 BOOL WINAPI _SHDesktopMessageLoop(HANDLE hDesktop)
82 {
83 HINSTANCE hFallback;
84
85 if (ghRShell)
86 {
87 PSHDESKTOPMESSAGELOOP func = (PSHDESKTOPMESSAGELOOP)GetProcAddress(ghRShell, "SHDesktopMessageLoop");
88 if (func)
89 {
90 return func(hDesktop);
91 }
92 }
93
94 hFallback = GetModuleHandleW(L"shell32.dll");
95
96 if (hFallback)
97 {
98 PSHDESKTOPMESSAGELOOP func = (PSHDESKTOPMESSAGELOOP) GetProcAddress(hFallback, (LPCSTR) 201);
99 if (func)
100 {
101 return func(hDesktop);
102 }
103 }
104
105 return FALSE;
106 }
107
108 typedef DWORD(WINAPI* PWINLIST_INIT)(void);
109
110 DWORD WINAPI _WinList_Init(void)
111 {
112 HINSTANCE hFallback;
113
114 if (ghRShell)
115 {
116 PWINLIST_INIT func = (PWINLIST_INIT)GetProcAddress(ghRShell, "WinList_Init");
117 if (func)
118 {
119 return func();
120 }
121 }
122
123 hFallback = LoadLibraryW(L"shdocvw.dll");
124
125 if (hFallback)
126 {
127 PWINLIST_INIT func = (PWINLIST_INIT) GetProcAddress(hFallback, (LPCSTR) 110);
128 if (func)
129 {
130 return func();
131 }
132 }
133
134 return 0;
135 }
136
137 typedef void (WINAPI *PSHELLDDEINIT)(BOOL bInit);
138
139 void WINAPI _ShellDDEInit(BOOL bInit)
140 {
141 HINSTANCE hFallback;
142
143 if (ghRShell)
144 {
145 PSHELLDDEINIT func = (PSHELLDDEINIT)GetProcAddress(ghRShell, "ShellDDEInit");
146 if (func)
147 {
148 func(bInit);
149 return;
150 }
151 }
152
153 hFallback = GetModuleHandleW(L"shell32.dll");
154
155 if (hFallback)
156 {
157 PSHELLDDEINIT func = (PSHELLDDEINIT) GetProcAddress(hFallback, (LPCSTR) 188);
158 if (func)
159 {
160 func(bInit);
161 return;
162 }
163 }
164 }
165
166 typedef HRESULT (WINAPI *CBANDSITEMENU_CREATEINSTANCE)(REFIID riid, void **ppv);
167 HRESULT WINAPI _CBandSiteMenu_CreateInstance(REFIID riid, void **ppv)
168 {
169 if (ghRShell)
170 {
171 CBANDSITEMENU_CREATEINSTANCE func = (CBANDSITEMENU_CREATEINSTANCE)GetProcAddress(ghRShell, "CBandSiteMenu_CreateInstance");
172 if (func)
173 {
174 return func(riid, ppv);
175 }
176 }
177
178 return CoCreateInstance(CLSID_BandSiteMenu,
179 NULL,
180 CLSCTX_INPROC_SERVER,
181 riid,
182 ppv);
183 }
184
185 typedef HRESULT (WINAPI *CBANDSITE_CREATEINSTANCE)(LPUNKNOWN pUnkOuter, REFIID riid, void **ppv);
186 HRESULT WINAPI _CBandSite_CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, void **ppv)
187 {
188 if (ghRShell)
189 {
190 CBANDSITE_CREATEINSTANCE func = (CBANDSITE_CREATEINSTANCE)GetProcAddress(ghRShell, "CBandSite_CreateInstance");
191 if (func)
192 {
193 return func(pUnkOuter, riid, ppv);
194 }
195 }
196
197 return CoCreateInstance(CLSID_RebarBandSite,
198 pUnkOuter,
199 CLSCTX_INPROC_SERVER,
200 riid,
201 ppv);
202 }
203