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 static VOID
InitializeAtlModule(HINSTANCE hInstance
, BOOL bInitialize
)
43 gModule
.Init(ObjectMap
, hInstance
, NULL
);
53 SetShellReadyEvent(IN LPCWSTR lpEventName
)
57 hEvent
= OpenEventW(EVENT_MODIFY_STATE
, FALSE
, lpEventName
);
70 HideMinimizedWindows(IN BOOL bHide
)
74 mm
.cbSize
= sizeof(mm
);
75 if (!SystemParametersInfoW(SPI_GETMINIMIZEDMETRICS
, sizeof(mm
), &mm
, 0))
77 ERR("SystemParametersInfoW failed with %lu\n", GetLastError());
81 mm
.iArrange
|= ARW_HIDE
;
83 mm
.iArrange
&= ~ARW_HIDE
;
84 if (!SystemParametersInfoW(SPI_SETMINIMIZEDMETRICS
, sizeof(mm
), &mm
, 0))
85 ERR("SystemParametersInfoW failed with %lu\n", GetLastError());
91 StartWithCommandLine(IN HINSTANCE hInstance
)
94 EXPLORER_CMDLINE_PARSE_RESULTS parseResults
= { 0 };
96 if (SHExplorerParseCmdLine(&parseResults
))
97 b
= SHCreateFromDesktop(&parseResults
);
99 if (parseResults
.strPath
)
100 SHFree(parseResults
.strPath
);
102 if (parseResults
.pidlPath
)
103 ILFree(parseResults
.pidlPath
);
105 if (parseResults
.pidlRoot
)
106 ILFree(parseResults
.pidlRoot
);
113 StartWithDesktop(IN HINSTANCE hInstance
)
115 InitializeAtlModule(hInstance
, TRUE
);
117 if (RegOpenKeyW(HKEY_CURRENT_USER
,
118 L
"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
119 &hkExplorer
) != ERROR_SUCCESS
)
122 LoadStringW(hInstance
, IDS_STARTUP_ERROR
, Message
, _countof(Message
));
123 MessageBox(NULL
, Message
, NULL
, MB_ICONERROR
);
127 hExplorerInstance
= hInstance
;
128 hProcessHeap
= GetProcessHeap();
130 g_TaskbarSettings
.Load();
132 InitCommonControls();
136 ProcessStartupItems();
139 #if !WIN7_COMPAT_MODE
140 /* Initialize shell dde support */
144 /* Initialize shell icons */
147 /* Initialize CLSID_ShellWindows class */
150 CComPtr
<ITrayWindow
> Tray
;
151 CreateTrayWindow(&Tray
);
154 /* This not only hides the minimized window captions in the bottom
155 left screen corner, but is also needed in order to receive
156 HSHELL_* notification messages (which are required for taskbar
157 buttons to work right) */
158 HideMinimizedWindows(TRUE
);
160 HANDLE hShellDesktop
= NULL
;
162 hShellDesktop
= DesktopCreateWindow(Tray
);
164 /* WinXP: Notify msgina to hide the welcome screen */
165 if (!SetShellReadyEvent(L
"msgina: ShellReadyEvent"))
166 SetShellReadyEvent(L
"Global\\msgina: ShellReadyEvent");
171 TrayMessageLoop(Tray
);
173 HideMinimizedWindows(FALSE
);
178 if (hShellDesktop
!= NULL
)
179 DesktopDestroyShellWindow(hShellDesktop
);
184 RegCloseKey(hkExplorer
);
187 InitializeAtlModule(hInstance
, FALSE
);
193 _tWinMain(IN HINSTANCE hInstance
,
194 IN HINSTANCE hPrevInstance
,
199 * Set our shutdown parameters: we want to shutdown the very last,
200 * but before any TaskMgr instance (which has a shutdown level of 1).
202 SetProcessShutdownParameters(2, 0);
206 #if !WIN7_COMPAT_MODE
207 BOOL CreateShellDesktop
= FALSE
;
209 TRACE("Explorer starting... Commandline: %S\n", lpCmdLine
);
211 if (GetShellWindow() == NULL
)
212 CreateShellDesktop
= TRUE
;
214 if (!CreateShellDesktop
)
216 return StartWithCommandLine(hInstance
);
220 return StartWithDesktop(hInstance
);