4 * Copyright 2006 - 2007 Thomas Weidenmueller <w3seek@reactos.org>
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.
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.
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
22 #include <browseui_undoc.h>
24 HINSTANCE hExplorerInstance
;
26 HKEY hkExplorer
= NULL
;
28 class CExplorerModule
: public CComModule
33 BEGIN_OBJECT_MAP(ObjectMap
)
36 CExplorerModule gModule
;
37 CAtlWinModule gWinModule
;
39 void *operator new (size_t, void *buf
)
44 static VOID
InitializeAtlModule(HINSTANCE hInstance
, BOOL bInitialize
)
48 gModule
.Init(ObjectMap
, hInstance
, NULL
);
58 SetShellReadyEvent(IN LPCWSTR lpEventName
)
62 hEvent
= OpenEventW(EVENT_MODIFY_STATE
, FALSE
, lpEventName
);
75 HideMinimizedWindows(IN BOOL bHide
)
79 mm
.cbSize
= sizeof(mm
);
80 if (!SystemParametersInfoW(SPI_GETMINIMIZEDMETRICS
, sizeof(mm
), &mm
, 0))
82 ERR("SystemParametersInfoW failed with %lu\n", GetLastError());
86 mm
.iArrange
|= ARW_HIDE
;
88 mm
.iArrange
&= ~ARW_HIDE
;
89 if (!SystemParametersInfoW(SPI_SETMINIMIZEDMETRICS
, sizeof(mm
), &mm
, 0))
90 ERR("SystemParametersInfoW failed with %lu\n", GetLastError());
96 StartWithCommandLine(IN HINSTANCE hInstance
)
99 EXPLORER_CMDLINE_PARSE_RESULTS parseResults
= { 0 };
101 if (SHExplorerParseCmdLine(&parseResults
))
102 b
= SHCreateFromDesktop(&parseResults
);
104 if (parseResults
.strPath
)
105 SHFree(parseResults
.strPath
);
107 if (parseResults
.pidlPath
)
108 ILFree(parseResults
.pidlPath
);
110 if (parseResults
.pidlRoot
)
111 ILFree(parseResults
.pidlRoot
);
118 StartWithDesktop(IN HINSTANCE hInstance
)
120 InitializeAtlModule(hInstance
, TRUE
);
122 if (RegOpenKeyW(HKEY_CURRENT_USER
,
123 L
"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
124 &hkExplorer
) != ERROR_SUCCESS
)
127 LoadStringW(hInstance
, IDS_STARTUP_ERROR
, Message
, _countof(Message
));
128 MessageBox(NULL
, Message
, NULL
, MB_ICONERROR
);
132 hExplorerInstance
= hInstance
;
133 hProcessHeap
= GetProcessHeap();
135 LoadAdvancedSettings();
136 InitCommonControls();
140 ProcessStartupItems();
143 #if !WIN7_COMPAT_MODE
144 /* Initialize shell dde support */
148 /* Initialize shell icons */
151 /* Initialize CLSID_ShellWindows class */
154 CComPtr
<ITrayWindow
> Tray
;
155 CreateTrayWindow(&Tray
);
158 /* This not only hides the minimized window captions in the bottom
159 left screen corner, but is also needed in order to receive
160 HSHELL_* notification messages (which are required for taskbar
161 buttons to work right) */
162 HideMinimizedWindows(TRUE
);
164 HANDLE hShellDesktop
= NULL
;
166 hShellDesktop
= DesktopCreateWindow(Tray
);
168 /* WinXP: Notify msgina to hide the welcome screen */
169 if (!SetShellReadyEvent(L
"msgina: ShellReadyEvent"))
170 SetShellReadyEvent(L
"Global\\msgina: ShellReadyEvent");
175 TrayMessageLoop(Tray
);
177 HideMinimizedWindows(FALSE
);
182 if (hShellDesktop
!= NULL
)
183 DesktopDestroyShellWindow(hShellDesktop
);
188 RegCloseKey(hkExplorer
);
191 InitializeAtlModule(hInstance
, FALSE
);
197 _tWinMain(IN HINSTANCE hInstance
,
198 IN HINSTANCE hPrevInstance
,
203 * Set our shutdown parameters: we want to shutdown the very last,
204 * but before any TaskMgr instance (which has a shutdown level of 1).
206 SetProcessShutdownParameters(2, 0);
208 #if !WIN7_COMPAT_MODE
209 BOOL CreateShellDesktop
= FALSE
;
211 TRACE("Explorer starting... Commandline: %S\n", lpCmdLine
);
213 if (GetShellWindow() == NULL
)
214 CreateShellDesktop
= TRUE
;
216 if (!CreateShellDesktop
)
218 return StartWithCommandLine(hInstance
);
222 return StartWithDesktop(hInstance
);