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 LoadTaskBarSettings();
131 InitCommonControls();
135 ProcessStartupItems();
138 #if !WIN7_COMPAT_MODE
139 /* Initialize shell dde support */
143 /* Initialize shell icons */
146 /* Initialize CLSID_ShellWindows class */
149 CComPtr
<ITrayWindow
> Tray
;
150 CreateTrayWindow(&Tray
);
153 /* This not only hides the minimized window captions in the bottom
154 left screen corner, but is also needed in order to receive
155 HSHELL_* notification messages (which are required for taskbar
156 buttons to work right) */
157 HideMinimizedWindows(TRUE
);
159 HANDLE hShellDesktop
= NULL
;
161 hShellDesktop
= DesktopCreateWindow(Tray
);
163 /* WinXP: Notify msgina to hide the welcome screen */
164 if (!SetShellReadyEvent(L
"msgina: ShellReadyEvent"))
165 SetShellReadyEvent(L
"Global\\msgina: ShellReadyEvent");
170 TrayMessageLoop(Tray
);
172 HideMinimizedWindows(FALSE
);
177 if (hShellDesktop
!= NULL
)
178 DesktopDestroyShellWindow(hShellDesktop
);
183 RegCloseKey(hkExplorer
);
186 InitializeAtlModule(hInstance
, FALSE
);
192 _tWinMain(IN HINSTANCE hInstance
,
193 IN HINSTANCE hPrevInstance
,
198 * Set our shutdown parameters: we want to shutdown the very last,
199 * but before any TaskMgr instance (which has a shutdown level of 1).
201 SetProcessShutdownParameters(2, 0);
205 #if !WIN7_COMPAT_MODE
206 BOOL CreateShellDesktop
= FALSE
;
208 TRACE("Explorer starting... Commandline: %S\n", lpCmdLine
);
210 if (GetShellWindow() == NULL
)
211 CreateShellDesktop
= TRUE
;
213 if (!CreateShellDesktop
)
215 return StartWithCommandLine(hInstance
);
219 return StartWithDesktop(hInstance
);