ReactOS 0.4.16-dev-1946-g52006dd
explorer.cpp File Reference
#include "precomp.h"
#include <browseui_undoc.h>
Include dependency graph for explorer.cpp:

Go to the source code of this file.

Classes

class  CExplorerModule
 

Functions

static VOID InitializeAtlModule (HINSTANCE hInstance, BOOL bInitialize)
 
static void InitializeServerAdminUI ()
 
static BOOL SetShellReadyEvent (IN LPCWSTR lpEventName)
 
static VOID HideMinimizedWindows (IN BOOL bHide)
 
static BOOL IsExplorerSystemShell ()
 
static INT StartWithCommandLine (IN HINSTANCE hInstance)
 
static INT StartWithDesktop (IN HINSTANCE hInstance)
 
INT WINAPI _tWinMain (IN HINSTANCE hInstance, IN HINSTANCE hPrevInstance, IN LPTSTR lpCmdLine, IN INT nCmdShow)
 

Variables

HINSTANCE hExplorerInstance
 
HANDLE hProcessHeap
 
HKEY hkExplorer = NULL
 
BOOL bExplorerIsShell = FALSE
 
CExplorerModule gModule
 
CAtlWinModule gWinModule
 

Function Documentation

◆ _tWinMain()

INT WINAPI _tWinMain ( IN HINSTANCE  hInstance,
IN HINSTANCE  hPrevInstance,
IN LPTSTR  lpCmdLine,
IN INT  nCmdShow 
)

Definition at line 261 of file explorer.cpp.

265{
266 /*
267 * Set our shutdown parameters: we want to shutdown the very last,
268 * but before any TaskMgr instance (which has a shutdown level of 1).
269 */
271
272 InitRSHELL();
273
274 TRACE("Explorer starting... Command line: %S\n", lpCmdLine);
275
276#if !WIN7_COMPAT_MODE
278
279 if (!bExplorerIsShell)
280 {
282 }
283#else
285#endif
286
288}
static BOOL IsExplorerSystemShell()
Definition: explorer.cpp:116
static INT StartWithCommandLine(IN HINSTANCE hInstance)
Definition: explorer.cpp:152
BOOL bExplorerIsShell
Definition: explorer.cpp:27
static INT StartWithDesktop(IN HINSTANCE hInstance)
Definition: explorer.cpp:174
VOID InitRSHELL(VOID)
Definition: rshell.cpp:27
HINSTANCE hInstance
Definition: charmap.c:19
#define NULL
Definition: types.h:112
BOOL WINAPI SetProcessShutdownParameters(IN DWORD dwLevel, IN DWORD dwFlags)
Definition: proc.c:949
#define TRACE(s)
Definition: solgame.cpp:4
HWND WINAPI GetShellWindow(void)
Definition: input.c:974

◆ HideMinimizedWindows()

static VOID HideMinimizedWindows ( IN BOOL  bHide)
static

Definition at line 96 of file explorer.cpp.

97{
99
100 mm.cbSize = sizeof(mm);
101 if (!SystemParametersInfoW(SPI_GETMINIMIZEDMETRICS, sizeof(mm), &mm, 0))
102 {
103 ERR("SystemParametersInfoW failed with %lu\n", GetLastError());
104 return;
105 }
106 if (bHide)
107 mm.iArrange |= ARW_HIDE;
108 else
109 mm.iArrange &= ~ARW_HIDE;
110 if (!SystemParametersInfoW(SPI_SETMINIMIZEDMETRICS, sizeof(mm), &mm, 0))
111 ERR("SystemParametersInfoW failed with %lu\n", GetLastError());
112}
#define ERR(fmt,...)
Definition: precomp.h:57
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define ARW_HIDE
Definition: winuser.h:1087
BOOL WINAPI SystemParametersInfoW(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)

Referenced by StartWithDesktop().

◆ InitializeAtlModule()

static VOID InitializeAtlModule ( HINSTANCE  hInstance,
BOOL  bInitialize 
)
static

Definition at line 40 of file explorer.cpp.

41{
42 if (bInitialize)
43 {
44 gModule.Init(ObjectMap, hInstance, NULL);
45 }
46 else
47 {
48 gModule.Term();
49 }
50}
CExplorerModule gModule
Definition: explorer.cpp:37
void Term()
Definition: atlbase.h:916
HRESULT Init(_ATL_OBJMAP_ENTRY *p, HINSTANCE, const GUID *plibid)
Definition: atlbase.h:886

Referenced by StartWithDesktop().

◆ InitializeServerAdminUI()

static void InitializeServerAdminUI ( )
static

Definition at line 53 of file explorer.cpp.

54{
56 if (!hKey)
57 return;
58
59 DWORD value, size = sizeof(value), type;
60 DWORD error = SHGetValueW(hKey, NULL, L"ServerAdminUI", &type, &value, &size);
61 if (error || type != REG_DWORD || size != sizeof(value))
62 {
63 // The value doesn't exist or is invalid, calculate and apply a default value
65 SHSetValueW(hKey, NULL, L"ServerAdminUI", REG_DWORD, &value, sizeof(value));
66 if (value)
67 {
68 // TODO: Apply registry tweaks with RegInstallW; RegServerAdmin in the REGINST resource in shell32.
69 #if !ROSPOLICY_SHELL_NODEFKEYBOARDCUES
71 #endif
72 }
73 }
75}
#define IntToPtr(i)
Definition: basetsd.h:83
#define RegCloseKey(hKey)
Definition: registry.h:49
#define TRUE
Definition: types.h:120
BOOL WINAPI IsOS(DWORD feature)
Definition: ordinal.c:4230
HKEY WINAPI SHGetShellKey(DWORD flags, LPCWSTR sub_key, BOOL create)
Definition: ordinal.c:4806
DWORD WINAPI SHGetValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue, LPDWORD pwType, LPVOID pvData, LPDWORD pcbData)
Definition: reg.c:1236
DWORD WINAPI SHSetValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue, DWORD dwType, LPCVOID pvData, DWORD cbData)
Definition: reg.c:1306
#define L(x)
Definition: resources.c:13
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
#define error(str)
Definition: mkdosfs.c:1605
@ SHKEY_Key_Explorer
Definition: ordinal.c:2807
@ SHKEY_Root_HKCU
Definition: ordinal.c:2805
#define OS_ANYSERVER
Definition: shlwapi.h:255
#define REG_DWORD
Definition: sdbapi.c:615
BOOL WINAPI IsUserAnAdmin(void)
Definition: shellord.c:2808
Definition: pdh_main.c:96
#define SPIF_SENDCHANGE
Definition: winuser.h:1600
#define SPIF_UPDATEINIFILE
Definition: winuser.h:1599
#define SystemParametersInfo
Definition: winuser.h:5969

Referenced by StartWithDesktop().

◆ IsExplorerSystemShell()

static BOOL IsExplorerSystemShell ( )
static

Definition at line 116 of file explorer.cpp.

117{
118 BOOL bIsSystemShell = TRUE; // Assume we are the system shell by default.
120
122 return FALSE;
123
124 LPWSTR szExplorer = PathFindFileNameW(szPath);
125
126 HKEY hKeyWinlogon;
128 L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
129 0, KEY_READ, &hKeyWinlogon) == ERROR_SUCCESS)
130 {
132 DWORD dwType;
133 WCHAR szShell[MAX_PATH];
134 DWORD cbShell = sizeof(szShell);
135
136 // TODO: Add support for paths longer than MAX_PATH
137 Status = RegQueryValueExW(hKeyWinlogon, L"Shell", 0, &dwType, (LPBYTE)szShell, &cbShell);
138 if (Status == ERROR_SUCCESS)
139 {
140 if ((dwType != REG_SZ && dwType != REG_EXPAND_SZ) || !StrStrIW(szShell, szExplorer))
141 bIsSystemShell = FALSE;
142 }
143
144 RegCloseKey(hKeyWinlogon);
145 }
146
147 return bIsSystemShell;
148}
#define ERROR_SUCCESS
Definition: deptool.c:10
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
#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 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 MAX_PATH
Definition: compat.h:34
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
WCHAR *WINAPI PathFindFileNameW(const WCHAR *path)
Definition: path.c:1701
unsigned int BOOL
Definition: ntddk_ex.h:94
Status
Definition: gdiplustypes.h:25
#define REG_SZ
Definition: layer.c:22
LPCWSTR szPath
Definition: env.c:37
#define KEY_READ
Definition: nt_native.h:1026
#define REG_EXPAND_SZ
Definition: nt_native.h:1497
#define _countof(array)
Definition: sndvol32.h:70
unsigned char * LPBYTE
Definition: typedefs.h:53
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by _tWinMain().

◆ SetShellReadyEvent()

static BOOL SetShellReadyEvent ( IN LPCWSTR  lpEventName)
static

Definition at line 79 of file explorer.cpp.

80{
82
84 if (hEvent != NULL)
85 {
87
89 return TRUE;
90 }
91
92 return FALSE;
93}
#define CloseHandle
Definition: compat.h:739
static HANDLE hEvent
Definition: comm.c:54
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
#define EVENT_MODIFY_STATE
Definition: winbase.h:165

Referenced by StartWithDesktop().

◆ StartWithCommandLine()

static INT StartWithCommandLine ( IN HINSTANCE  hInstance)
static

Definition at line 152 of file explorer.cpp.

153{
154 BOOL b = FALSE;
155 EXPLORER_CMDLINE_PARSE_RESULTS parseResults = { 0 };
156
157 if (SHExplorerParseCmdLine(&parseResults))
158 b = SHCreateFromDesktop(&parseResults);
159
160 if (parseResults.strPath)
161 SHFree(parseResults.strPath);
162
163 if (parseResults.pidlPath)
164 ILFree(parseResults.pidlPath);
165
166 if (parseResults.pidlRoot)
167 ILFree(parseResults.pidlRoot);
168
169 return b;
170}
BOOL WINAPI SHCreateFromDesktop(_In_ PEXPLORER_CMDLINE_PARSE_RESULTS parseResults)
Definition: desktopipc.cpp:619
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:370
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define b
Definition: ke_i.h:79
UINT_PTR WINAPI SHExplorerParseCmdLine(_Out_ PEXPLORER_CMDLINE_PARSE_RESULTS pInfo)
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:1045

Referenced by _tWinMain().

◆ StartWithDesktop()

static INT StartWithDesktop ( IN HINSTANCE  hInstance)
static

Definition at line 174 of file explorer.cpp.

175{
177
179 L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
181 {
182 WCHAR Message[256];
185 return 1;
186 }
187
190
192
195
196#if !WIN7_COMPAT_MODE
197 /* Initialize shell dde support */
199#endif
200
201 /* Initialize shell icons */
203
204 /* Initialize CLSID_ShellWindows class */
206
208
210 CreateTrayWindow(&Tray);
211
212#if !WIN7_DEBUG_MODE
213 /* This not only hides the minimized window captions in the bottom
214 left screen corner, but is also needed in order to receive
215 HSHELL_* notification messages (which are required for taskbar
216 buttons to work right) */
218
219 ProcessRunOnceItems(); // Must be executed before the desktop is created
220
221 HANDLE hShellDesktop = NULL;
222 if (Tray != NULL)
223 hShellDesktop = DesktopCreateWindow(Tray);
224
225 /* WinXP: Notify msgina to hide the welcome screen */
226 if (!SetShellReadyEvent(L"msgina: ShellReadyEvent"))
227 SetShellReadyEvent(L"Global\\msgina: ShellReadyEvent");
228
229 if (DoStartStartupItems(Tray))
230 {
233 }
234 ReleaseStartupMutex(); // For ProcessRunOnceItems
235#endif
236
237 if (Tray != NULL)
238 {
239 TrayMessageLoop(Tray);
240#if !WIN7_DEBUG_MODE
242#endif
243 }
244
245#if !WIN7_DEBUG_MODE
246 if (hShellDesktop != NULL)
247 DesktopDestroyShellWindow(hShellDesktop);
248#endif
249
251
254
256
257 return 0;
258}
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
static VOID HideMinimizedWindows(IN BOOL bHide)
Definition: explorer.cpp:96
static BOOL SetShellReadyEvent(IN LPCWSTR lpEventName)
Definition: explorer.cpp:79
static void InitializeServerAdminUI()
Definition: explorer.cpp:53
HINSTANCE hExplorerInstance
Definition: explorer.cpp:24
HKEY hkExplorer
Definition: explorer.cpp:26
HANDLE hProcessHeap
Definition: explorer.cpp:25
VOID TrayMessageLoop(IN OUT ITrayWindow *Tray)
static VOID DoFinishStartupItems()
Definition: precomp.h:263
VOID ReleaseStartupMutex()
Definition: startup.cpp:513
void WINAPI _ShellDDEInit(BOOL bInit)
Definition: rshell.cpp:139
HRESULT CreateTrayWindow(ITrayWindow **ppTray)
Definition: traywnd.cpp:3722
TaskbarSettings g_TaskbarSettings
Definition: settings.cpp:23
VOID ProcessRunOnceItems()
Definition: startup.cpp:588
static INT ProcessStartupItems()
Definition: precomp.h:262
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
VOID WINAPI InitCommonControls(void)
Definition: commctrl.c:874
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3268
#define GetProcessHeap()
Definition: compat.h:736
INT WINAPI DECLSPEC_HOTPATCH LoadStringW(HINSTANCE instance, UINT resource_id, LPWSTR buffer, INT buflen)
Definition: string.c:1220
HRESULT WINAPI DECLSPEC_HOTPATCH OleInitialize(LPVOID reserved)
Definition: ole2.c:169
void WINAPI DECLSPEC_HOTPATCH OleUninitialize(void)
Definition: ole2.c:230
static const WCHAR Message[]
Definition: register.c:74
BOOL WINAPI FileIconInit(BOOL bFullInit)
Definition: shellord.c:1889
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define MB_ICONERROR
Definition: winuser.h:798
#define MessageBox
Definition: winuser.h:5933

Referenced by _tWinMain().

Variable Documentation

◆ bExplorerIsShell

BOOL bExplorerIsShell = FALSE

◆ gModule

CExplorerModule gModule

Definition at line 37 of file explorer.cpp.

Referenced by InitializeAtlModule().

◆ gWinModule

CAtlWinModule gWinModule

Definition at line 38 of file explorer.cpp.

◆ hExplorerInstance

◆ hkExplorer

◆ hProcessHeap