3690bbfcbc6080cb6084b8c196eec59d85cdc45b
[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 hRShell = NULL;
24
25 typedef HRESULT(WINAPI * PSTARTMENU_CONSTRUCTOR)(REFIID riid, void **ppv);
26
27 HRESULT WINAPI _CStartMenu_Constructor(REFIID riid, void **ppv)
28 {
29 if (!hRShell)
30 {
31 hRShell = LoadLibraryW(L"rshell.dll");
32 }
33
34 if (hRShell)
35 {
36 PSTARTMENU_CONSTRUCTOR func = (PSTARTMENU_CONSTRUCTOR)GetProcAddress(hRShell, "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 (!hRShell)
57 {
58 hRShell = LoadLibraryW(L"rshell.dll");
59 }
60
61 if (hRShell)
62 {
63 PSHCREATEDESKTOP func = (PSHCREATEDESKTOP)GetProcAddress(hRShell, "SHCreateDesktop");
64 if (func)
65 {
66 return func(ShellDesk);
67 }
68 }
69
70 hFallback = GetModuleHandleW(L"shell32.dll");
71
72 if (hFallback)
73 {
74 PSHCREATEDESKTOP func = (PSHCREATEDESKTOP) GetProcAddress(hFallback, (LPCSTR) 200);
75 if (func)
76 {
77 return func(ShellDesk);
78 }
79 }
80
81 return 0;
82 }
83
84 typedef BOOL(WINAPI *PSHDESKTOPMESSAGELOOP)(HANDLE hDesktop);
85
86 BOOL WINAPI _SHDesktopMessageLoop(HANDLE hDesktop)
87 {
88 HINSTANCE hFallback;
89
90 if (!hRShell)
91 {
92 hRShell = LoadLibraryW(L"rshell.dll");
93 }
94
95 if (hRShell)
96 {
97 PSHDESKTOPMESSAGELOOP func = (PSHDESKTOPMESSAGELOOP)GetProcAddress(hRShell, "SHDesktopMessageLoop");
98 if (func)
99 {
100 return func(hDesktop);
101 }
102 }
103
104 hFallback = GetModuleHandleW(L"shell32.dll");
105
106 if (hFallback)
107 {
108 PSHDESKTOPMESSAGELOOP func = (PSHDESKTOPMESSAGELOOP) GetProcAddress(hFallback, (LPCSTR) 201);
109 if (func)
110 {
111 return func(hDesktop);
112 }
113 }
114
115 return FALSE;
116 }
117
118 typedef DWORD(WINAPI* PWINLIST_INIT)(void);
119
120 DWORD WINAPI _WinList_Init(void)
121 {
122 HINSTANCE hFallback;
123
124 if (!hRShell)
125 {
126 hRShell = LoadLibraryW(L"rshell.dll");
127 }
128
129 if (hRShell)
130 {
131 PWINLIST_INIT func = (PWINLIST_INIT)GetProcAddress(hRShell, "WinList_Init");
132 if (func)
133 {
134 return func();
135 }
136 }
137
138 hFallback = LoadLibraryW(L"shdocvw.dll");
139
140 if (hFallback)
141 {
142 PWINLIST_INIT func = (PWINLIST_INIT) GetProcAddress(hFallback, (LPCSTR) 110);
143 if (func)
144 {
145 return func();
146 }
147 }
148
149 return 0;
150 }
151
152 typedef void (WINAPI *PSHELLDDEINIT)(BOOL bInit);
153
154 void WINAPI _ShellDDEInit(BOOL bInit)
155 {
156 HINSTANCE hFallback;
157
158 if (!hRShell)
159 {
160 hRShell = LoadLibraryW(L"rshell.dll");
161 }
162
163 if (hRShell)
164 {
165 PSHELLDDEINIT func = (PSHELLDDEINIT)GetProcAddress(hRShell, "ShellDDEInit");
166 if (func)
167 {
168 func(bInit);
169 return;
170 }
171 }
172
173 hFallback = GetModuleHandleW(L"shell32.dll");
174
175 if (hFallback)
176 {
177 PSHELLDDEINIT func = (PSHELLDDEINIT) GetProcAddress(hFallback, (LPCSTR) 188);
178 if (func)
179 {
180 func(bInit);
181 return;
182 }
183 }
184 }