ReactOS 0.4.16-dev-852-gcfcc8d8
explorer.cpp
Go to the documentation of this file.
1/*
2 * ReactOS Explorer
3 *
4 * Copyright 2006 - 2007 Thomas Weidenmueller <w3seek@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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include "precomp.h"
22#include <browseui_undoc.h>
23
28
30{
31public:
32};
33
34BEGIN_OBJECT_MAP(ObjectMap)
36
39
41{
42 if (bInitialize)
43 {
44 gModule.Init(ObjectMap, hInstance, NULL);
45 }
46 else
47 {
48 gModule.Term();
49 }
50}
51
52#if !WIN7_DEBUG_MODE
53static BOOL
55{
57
59 if (hEvent != NULL)
60 {
62
64 return TRUE;
65 }
66
67 return FALSE;
68}
69
70static VOID
72{
74
75 mm.cbSize = sizeof(mm);
76 if (!SystemParametersInfoW(SPI_GETMINIMIZEDMETRICS, sizeof(mm), &mm, 0))
77 {
78 ERR("SystemParametersInfoW failed with %lu\n", GetLastError());
79 return;
80 }
81 if (bHide)
82 mm.iArrange |= ARW_HIDE;
83 else
84 mm.iArrange &= ~ARW_HIDE;
85 if (!SystemParametersInfoW(SPI_SETMINIMIZEDMETRICS, sizeof(mm), &mm, 0))
86 ERR("SystemParametersInfoW failed with %lu\n", GetLastError());
87}
88#endif
89
90static BOOL
92{
93 BOOL bIsSystemShell = TRUE; // Assume we are the system shell by default.
95
97 return FALSE;
98
99 LPWSTR szExplorer = PathFindFileNameW(szPath);
100
101 HKEY hKeyWinlogon;
103 L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
104 0, KEY_READ, &hKeyWinlogon) == ERROR_SUCCESS)
105 {
107 DWORD dwType;
108 WCHAR szShell[MAX_PATH];
109 DWORD cbShell = sizeof(szShell);
110
111 // TODO: Add support for paths longer than MAX_PATH
112 Status = RegQueryValueExW(hKeyWinlogon, L"Shell", 0, &dwType, (LPBYTE)szShell, &cbShell);
113 if (Status == ERROR_SUCCESS)
114 {
115 if ((dwType != REG_SZ && dwType != REG_EXPAND_SZ) || !StrStrIW(szShell, szExplorer))
116 bIsSystemShell = FALSE;
117 }
118
119 RegCloseKey(hKeyWinlogon);
120 }
121
122 return bIsSystemShell;
123}
124
125#if !WIN7_COMPAT_MODE
126static INT
128{
129 BOOL b = FALSE;
130 EXPLORER_CMDLINE_PARSE_RESULTS parseResults = { 0 };
131
132 if (SHExplorerParseCmdLine(&parseResults))
133 b = SHCreateFromDesktop(&parseResults);
134
135 if (parseResults.strPath)
136 SHFree(parseResults.strPath);
137
138 if (parseResults.pidlPath)
139 ILFree(parseResults.pidlPath);
140
141 if (parseResults.pidlRoot)
142 ILFree(parseResults.pidlRoot);
143
144 return b;
145}
146#endif
147
148static INT
150{
152
154 L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
156 {
157 WCHAR Message[256];
160 return 1;
161 }
162
165
167
170
171#if !WIN7_COMPAT_MODE
172 /* Initialize shell dde support */
174#endif
175
176 /* Initialize shell icons */
178
179 /* Initialize CLSID_ShellWindows class */
181
183 CreateTrayWindow(&Tray);
184
185#if !WIN7_DEBUG_MODE
186 /* This not only hides the minimized window captions in the bottom
187 left screen corner, but is also needed in order to receive
188 HSHELL_* notification messages (which are required for taskbar
189 buttons to work right) */
191
192 ProcessRunOnceItems(); // Must be executed before the desktop is created
193
194 HANDLE hShellDesktop = NULL;
195 if (Tray != NULL)
196 hShellDesktop = DesktopCreateWindow(Tray);
197
198 /* WinXP: Notify msgina to hide the welcome screen */
199 if (!SetShellReadyEvent(L"msgina: ShellReadyEvent"))
200 SetShellReadyEvent(L"Global\\msgina: ShellReadyEvent");
201
202 if (DoStartStartupItems(Tray))
203 {
206 }
207 ReleaseStartupMutex(); // For ProcessRunOnceItems
208#endif
209
210 if (Tray != NULL)
211 {
212 TrayMessageLoop(Tray);
213#if !WIN7_DEBUG_MODE
215#endif
216 }
217
218#if !WIN7_DEBUG_MODE
219 if (hShellDesktop != NULL)
220 DesktopDestroyShellWindow(hShellDesktop);
221#endif
222
224
227
229
230 return 0;
231}
232
235 IN HINSTANCE hPrevInstance,
236 IN LPTSTR lpCmdLine,
237 IN INT nCmdShow)
238{
239 /*
240 * Set our shutdown parameters: we want to shutdown the very last,
241 * but before any TaskMgr instance (which has a shutdown level of 1).
242 */
244
245 InitRSHELL();
246
247 TRACE("Explorer starting... Command line: %S\n", lpCmdLine);
248
249#if !WIN7_COMPAT_MODE
251
252 if (!bExplorerIsShell)
253 {
255 }
256#else
258#endif
259
261}
#define ERR(fmt,...)
Definition: precomp.h:57
VOID DesktopDestroyShellWindow(IN HANDLE hDesktop)
Definition: desktop.cpp:203
HANDLE DesktopCreateWindow(IN OUT ITrayWindow *Tray)
Definition: desktop.cpp:188
static VOID InitializeAtlModule(HINSTANCE hInstance, BOOL bInitialize)
Definition: explorer.cpp:40
CAtlWinModule gWinModule
Definition: explorer.cpp:38
static BOOL IsExplorerSystemShell()
Definition: explorer.cpp:91
static VOID HideMinimizedWindows(IN BOOL bHide)
Definition: explorer.cpp:71
static INT StartWithCommandLine(IN HINSTANCE hInstance)
Definition: explorer.cpp:127
CExplorerModule gModule
Definition: explorer.cpp:37
BOOL bExplorerIsShell
Definition: explorer.cpp:27
static BOOL SetShellReadyEvent(IN LPCWSTR lpEventName)
Definition: explorer.cpp:54
HINSTANCE hExplorerInstance
Definition: explorer.cpp:24
HKEY hkExplorer
Definition: explorer.cpp:26
HANDLE hProcessHeap
Definition: explorer.cpp:25
static INT StartWithDesktop(IN HINSTANCE hInstance)
Definition: explorer.cpp:149
VOID TrayMessageLoop(IN OUT ITrayWindow *Tray)
static VOID DoFinishStartupItems()
Definition: precomp.h:261
VOID ReleaseStartupMutex()
Definition: startup.cpp:513
void WINAPI _ShellDDEInit(BOOL bInit)
Definition: rshell.cpp:139
HRESULT CreateTrayWindow(ITrayWindow **ppTray)
Definition: traywnd.cpp:3708
TaskbarSettings g_TaskbarSettings
Definition: settings.cpp:23
VOID ProcessRunOnceItems()
Definition: startup.cpp:588
static INT ProcessStartupItems()
Definition: precomp.h:260
VOID InitRSHELL(VOID)
Definition: rshell.cpp:27
BOOL DoStartStartupItems(ITrayWindow *Tray)
Definition: startup.cpp:549
BOOL WINAPI _WinList_Init(void)
Definition: rshell.cpp:110
#define IDS_STARTUP_ERROR
Definition: resource.h:104
#define RegCloseKey(hKey)
Definition: registry.h:49
HINSTANCE hInstance
Definition: charmap.c:19
void Term()
Definition: atlbase.h:916
HRESULT Init(_ATL_OBJMAP_ENTRY *p, HINSTANCE, const GUID *plibid)
Definition: atlbase.h:886
VOID WINAPI InitCommonControls(void)
Definition: commctrl.c:870
#define ERROR_SUCCESS
Definition: deptool.c:10
BOOL WINAPI SHCreateFromDesktop(_In_ PEXPLORER_CMDLINE_PARSE_RESULTS parseResults)
Definition: desktopipc.cpp:619
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3268
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
LPWSTR WINAPI StrStrIW(LPCWSTR lpszStr, LPCWSTR lpszSearch)
Definition: string.c:380
#define CloseHandle
Definition: compat.h:739
#define GetProcessHeap()
Definition: compat.h:736
#define MAX_PATH
Definition: compat.h:34
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
BOOL WINAPI SetProcessShutdownParameters(IN DWORD dwLevel, IN DWORD dwFlags)
Definition: proc.c:949
HRESULT WINAPI DECLSPEC_HOTPATCH OleInitialize(LPVOID reserved)
Definition: ole2.c:169
void WINAPI DECLSPEC_HOTPATCH OleUninitialize(void)
Definition: ole2.c:230
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:326
LPWSTR WINAPI PathFindFileNameW(LPCWSTR lpszPath)
Definition: path.c:394
static const WCHAR Message[]
Definition: register.c:74
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
Status
Definition: gdiplustypes.h:25
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define _tWinMain
Definition: tchar.h:498
#define b
Definition: ke_i.h:79
#define REG_SZ
Definition: layer.c:22
#define END_OBJECT_MAP()
Definition: atlcom.h:691
#define BEGIN_OBJECT_MAP(x)
Definition: atlcom.h:689
LPCWSTR szPath
Definition: env.c:37
static HANDLE hEvent
Definition: comm.c:54
#define KEY_READ
Definition: nt_native.h:1023
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define L(x)
Definition: ntvdm.h:50
UINT_PTR WINAPI SHExplorerParseCmdLine(_Out_ PEXPLORER_CMDLINE_PARSE_RESULTS pInfo)
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:1044
BOOL WINAPI FileIconInit(BOOL bFullInit)
Definition: shellord.c:1888
#define _countof(array)
Definition: sndvol32.h:70
#define TRACE(s)
Definition: solgame.cpp:4
HANDLE WINAPI DECLSPEC_HOTPATCH OpenEventW(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCWSTR lpName)
Definition: synch.c:682
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
unsigned char * LPBYTE
Definition: typedefs.h:53
int32_t INT
Definition: typedefs.h:58
#define IN
Definition: typedefs.h:39
HWND WINAPI GetShellWindow(void)
Definition: input.c:974
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define EVENT_MODIFY_STATE
Definition: winbase.h:164
#define WINAPI
Definition: msvc.h:6
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define ARW_HIDE
Definition: winuser.h:1079
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define MB_ICONERROR
Definition: winuser.h:790
BOOL WINAPI SystemParametersInfoW(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)
#define MessageBox
Definition: winuser.h:5834
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
CHAR * LPTSTR
Definition: xmlstorage.h:192
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185