[EXPLORER] -If rshell is present and CBandSiteMenu_CreateInstance or CBandSite_Create...
[reactos.git] / reactos / base / shell / explorer / explorer.cpp
index 187201a..cdcdb1c 100644 (file)
 #include <browseui_undoc.h>
 
 HINSTANCE hExplorerInstance;
-HMODULE hUser32;
 HANDLE hProcessHeap;
 HKEY hkExplorer = NULL;
-DRAWCAPTEMP DrawCapTemp = NULL;
 
 class CExplorerModule : public CComModule
 {
@@ -47,12 +45,6 @@ static VOID InitializeAtlModule(HINSTANCE hInstance, BOOL bInitialize)
 {
     if (bInitialize)
     {
-        /* HACK - the global constructors don't run, so I placement new them here */
-        new (&gModule) CExplorerModule;
-        new (&gWinModule) CAtlWinModule;
-        new (&_AtlBaseModule) CAtlBaseModule;
-        new (&_AtlComModule) CAtlComModule;
-
         gModule.Init(ObjectMap, hInstance, NULL);
     }
     else
@@ -61,13 +53,13 @@ static VOID InitializeAtlModule(HINSTANCE hInstance, BOOL bInitialize)
     }
 }
 
-#if !WIN7_COMPAT_MODE
+#if !WIN7_DEBUG_MODE
 static BOOL
-SetShellReadyEvent(IN LPCTSTR lpEventName)
+SetShellReadyEvent(IN LPCWSTR lpEventName)
 {
     HANDLE hEvent;
 
-    hEvent = OpenEvent(EVENT_MODIFY_STATE, FALSE, lpEventName);
+    hEvent = OpenEventW(EVENT_MODIFY_STATE, FALSE, lpEventName);
     if (hEvent != NULL)
     {
         SetEvent(hEvent);
@@ -85,19 +77,21 @@ HideMinimizedWindows(IN BOOL bHide)
     MINIMIZEDMETRICS mm;
 
     mm.cbSize = sizeof(mm);
-    if (!SystemParametersInfo(SPI_GETMINIMIZEDMETRICS, sizeof(mm), &mm, 0))
+    if (!SystemParametersInfoW(SPI_GETMINIMIZEDMETRICS, sizeof(mm), &mm, 0))
     {
-        ERR("SystemParametersInfo failed with %lu\n", GetLastError());
+        ERR("SystemParametersInfoW failed with %lu\n", GetLastError());
         return;
     }
     if (bHide)
         mm.iArrange |= ARW_HIDE;
     else
         mm.iArrange &= ~ARW_HIDE;
-    if (!SystemParametersInfo(SPI_SETMINIMIZEDMETRICS, sizeof(mm), &mm, 0))
-        ERR("SystemParametersInfo failed with %lu\n", GetLastError());
+    if (!SystemParametersInfoW(SPI_SETMINIMIZEDMETRICS, sizeof(mm), &mm, 0))
+        ERR("SystemParametersInfoW failed with %lu\n", GetLastError());
 }
+#endif
 
+#if !WIN7_COMPAT_MODE
 static INT 
 StartWithCommandLine(IN HINSTANCE hInstance)
 {
@@ -125,32 +119,28 @@ StartWithDesktop(IN HINSTANCE hInstance)
 {
     InitializeAtlModule(hInstance, TRUE);
 
-    if (RegOpenKey(HKEY_CURRENT_USER,
+    if (RegOpenKeyW(HKEY_CURRENT_USER,
         L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
         &hkExplorer) != ERROR_SUCCESS)
     {
         WCHAR Message[256];
-        LoadString(hInstance, IDS_STARTUP_ERROR, Message, 256);
+        LoadStringW(hInstance, IDS_STARTUP_ERROR, Message, _countof(Message));
         MessageBox(NULL, Message, NULL, MB_ICONERROR);
         return 1;
     }
 
     hExplorerInstance = hInstance;
     hProcessHeap = GetProcessHeap();
-    LoadAdvancedSettings();
-
-    hUser32 = GetModuleHandle(TEXT("USER32.DLL"));
-    if (hUser32 != NULL)
-    {
-        DrawCapTemp = (DRAWCAPTEMP) GetProcAddress(hUser32, PROC_NAME_DRAWCAPTIONTEMP);
-    }
 
+    LoadTaskBarSettings();
     InitCommonControls();
     OleInitialize(NULL);
 
-#if !WIN7_COMPAT_MODE
+#if !WIN7_DEBUG_MODE
     ProcessStartupItems();
+#endif
 
+#if !WIN7_COMPAT_MODE
     /* Initialize shell dde support */
     _ShellDDEInit(TRUE);
 #endif
@@ -164,7 +154,7 @@ StartWithDesktop(IN HINSTANCE hInstance)
     CComPtr<ITrayWindow> Tray;
     CreateTrayWindow(&Tray);
 
-#if !WIN7_COMPAT_MODE
+#if !WIN7_DEBUG_MODE
     /* This not only hides the minimized window captions in the bottom
     left screen corner, but is also needed in order to receive
     HSHELL_* notification messages (which are required for taskbar
@@ -176,19 +166,19 @@ StartWithDesktop(IN HINSTANCE hInstance)
         hShellDesktop = DesktopCreateWindow(Tray);
 
     /* WinXP: Notify msgina to hide the welcome screen */
-    if (!SetShellReadyEvent(TEXT("msgina: ShellReadyEvent")))
-        SetShellReadyEvent(TEXT("Global\\msgina: ShellReadyEvent"));
+    if (!SetShellReadyEvent(L"msgina: ShellReadyEvent"))
+        SetShellReadyEvent(L"Global\\msgina: ShellReadyEvent");
 #endif
 
     if (Tray != NULL)
     {
         TrayMessageLoop(Tray);
-#if !WIN7_COMPAT_MODE
+#if !WIN7_DEBUG_MODE
         HideMinimizedWindows(FALSE);
 #endif
     }
 
-#if !WIN7_COMPAT_MODE
+#if !WIN7_DEBUG_MODE
     if (hShellDesktop != NULL)
         DesktopDestroyShellWindow(hShellDesktop);
 #endif
@@ -209,17 +199,19 @@ _tWinMain(IN HINSTANCE hInstance,
           IN LPTSTR lpCmdLine,
           IN INT nCmdShow)
 {
-#if !WIN7_COMPAT_MODE
-    BOOL CreateShellDesktop = FALSE;
-
-    TRACE("Explorer starting... Commandline: %S\n", lpCmdLine);
-
     /*
     * Set our shutdown parameters: we want to shutdown the very last,
     * but before any TaskMgr instance (which has a shutdown level of 1).
     */
     SetProcessShutdownParameters(2, 0);
 
+    InitRSHELL();
+
+#if !WIN7_COMPAT_MODE
+    BOOL CreateShellDesktop = FALSE;
+
+    TRACE("Explorer starting... Commandline: %S\n", lpCmdLine);
+
     if (GetShellWindow() == NULL)
         CreateShellDesktop = TRUE;