[USERINIT]
[reactos.git] / reactos / base / system / userinit / userinit.c
index 6b81fe3..81027d4 100644 (file)
@@ -12,9 +12,9 @@
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
  *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 /*
  * COPYRIGHT:   See COPYING in the top level directory
@@ -30,6 +30,7 @@
 #include <shlwapi.h>
 #include "resource.h"
 #include <wine/debug.h>
+#include <win32k/ntusrtyp.h>
 
 WINE_DEFAULT_DEBUG_CHANNEL(userinit);
 
@@ -120,7 +121,7 @@ BOOL IsConsoleShell(VOID)
         NextOption = wcschr(CurrentOption, L' ');
         if (NextOption)
             *NextOption = L'\0';
-        if (wcsicmp(CurrentOption, L"CONSOLE") == 0)
+        if (_wcsicmp(CurrentOption, L"CONSOLE") == 0)
         {
             TRACE("Found 'CONSOLE' boot option\n");
             ret = TRUE;
@@ -211,7 +212,6 @@ StartAutoApplications(
         WARN("FindFirstFile(%s) failed with error %lu\n", debugstr_w(szPath), GetLastError());
         return;
     }
-    szPath[len] = L'\0';
 
     do
     {
@@ -219,9 +219,10 @@ StartAutoApplications(
         {
             memset(&ExecInfo, 0x0, sizeof(SHELLEXECUTEINFOW));
             ExecInfo.cbSize = sizeof(ExecInfo);
+            wcscpy(&szPath[len+1], findData.cFileName);
             ExecInfo.lpVerb = L"open";
-            ExecInfo.lpFile = findData.cFileName;
-            ExecInfo.lpDirectory = szPath;
+            ExecInfo.lpFile = szPath;
+            ExecInfo.lpDirectory = NULL;
             TRACE("Executing %s in directory %s\n",
                 debugstr_w(findData.cFileName), debugstr_w(szPath));
             ShellExecuteExW(&ExecInfo);
@@ -400,99 +401,10 @@ VOID SetUserSysColors(VOID)
     RegCloseKey(hKey);
 }
 
-static
-VOID LoadUserFontSetting(
-    IN LPWSTR lpValueName,
-    OUT PLOGFONTW pFont)
-{
-    HKEY hKey;
-    LOGFONTW lfTemp;
-    DWORD Type, Size;
-    LONG rc;
+DWORD
+WINAPI
+UpdatePerUserSystemParameters(DWORD dw1, BOOL bEnable);
 
-    TRACE("(%s, %p)\n", debugstr_w(lpValueName), pFont);
-
-    Size = sizeof(LOGFONTW);
-    rc = RegOpenKeyEx(HKEY_CURRENT_USER, REGSTR_PATH_METRICS,
-                      0, KEY_QUERY_VALUE, &hKey);
-    if (rc != ERROR_SUCCESS)
-    {
-        WARN("RegOpenKeyEx() failed with error %lu\n", rc);
-        return;
-    }
-    rc = RegQueryValueEx(hKey, lpValueName, NULL, &Type, (LPBYTE)&lfTemp, &Size);
-    if (rc != ERROR_SUCCESS || Type != REG_BINARY)
-    {
-        WARN("RegQueryValueEx() failed with error %lu\n", rc);
-        return;
-    }
-    RegCloseKey(hKey);
-    /* FIXME: Check if lfTemp is a valid font */
-    *pFont = lfTemp;
-}
-
-static
-VOID LoadUserMetricSetting(
-    IN LPWSTR lpValueName,
-    OUT INT *pValue)
-{
-    HKEY hKey;
-    DWORD Type, Size;
-    WCHAR strValue[8];
-    LONG rc;
-
-    TRACE("(%s, %p)\n", debugstr_w(lpValueName), pValue);
-
-    Size = sizeof(strValue);
-    rc = RegOpenKeyEx(HKEY_CURRENT_USER, REGSTR_PATH_METRICS,
-                      0, KEY_QUERY_VALUE, &hKey);
-    if (rc != ERROR_SUCCESS)
-    {
-        WARN("RegOpenKeyEx() failed with error %lu\n", rc);
-        return;
-    }
-    rc = RegQueryValueEx(hKey, lpValueName, NULL, &Type, (LPBYTE)&strValue, &Size);
-    if (rc != ERROR_SUCCESS || Type != REG_SZ)
-    {
-        WARN("RegQueryValueEx() failed with error %lu\n", rc);
-        return;
-    }
-    RegCloseKey(hKey);
-    *pValue = StrToInt(strValue);
-}
-
-static
-VOID SetUserMetrics(VOID)
-{
-    NONCLIENTMETRICSW ncmetrics;
-    MINIMIZEDMETRICS mmmetrics;
-
-    TRACE("()\n");
-
-    ncmetrics.cbSize = sizeof(NONCLIENTMETRICSW);
-    mmmetrics.cbSize = sizeof(MINIMIZEDMETRICS);
-    SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICSW), &ncmetrics, 0);
-    SystemParametersInfoW(SPI_GETMINIMIZEDMETRICS, sizeof(MINIMIZEDMETRICS), &mmmetrics, 0);
-
-    LoadUserFontSetting(L"CaptionFont", &ncmetrics.lfCaptionFont);
-    LoadUserFontSetting(L"SmCaptionFont", &ncmetrics.lfSmCaptionFont);
-    LoadUserFontSetting(L"MenuFont", &ncmetrics.lfMenuFont);
-    LoadUserFontSetting(L"StatusFont", &ncmetrics.lfStatusFont);
-    LoadUserFontSetting(L"MessageFont", &ncmetrics.lfMessageFont);
-    /* FIXME: load icon font ? */
-
-    LoadUserMetricSetting(L"BorderWidth", &ncmetrics.iBorderWidth);
-    LoadUserMetricSetting(L"ScrollWidth", &ncmetrics.iScrollWidth);
-    LoadUserMetricSetting(L"ScrollHeight", &ncmetrics.iScrollHeight);
-    LoadUserMetricSetting(L"CaptionWidth", &ncmetrics.iCaptionWidth);
-    LoadUserMetricSetting(L"CaptionHeight", &ncmetrics.iCaptionHeight);
-    LoadUserMetricSetting(L"SmCaptionWidth", &ncmetrics.iSmCaptionWidth);
-    LoadUserMetricSetting(L"SmCaptionHeight", &ncmetrics.iSmCaptionHeight);
-    LoadUserMetricSetting(L"Menuwidth", &ncmetrics.iMenuWidth);
-    LoadUserMetricSetting(L"MenuHeight", &ncmetrics.iMenuHeight);
-
-    SystemParametersInfoW(SPI_SETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICSW), &ncmetrics, 0);
-}
 
 static
 VOID SetUserWallpaper(VOID)
@@ -540,8 +452,8 @@ VOID SetUserSettings(VOID)
 {
     TRACE("()\n");
 
+    UpdatePerUserSystemParameters(1, TRUE);
     SetUserSysColors();
-    SetUserMetrics();
     SetUserWallpaper();
 }
 
@@ -580,9 +492,9 @@ wWinMain(IN HINSTANCE hInst,
          IN LPWSTR lpszCmdLine,
          IN int nCmdShow)
 {
-    NotifyLogon();
     SetUserSettings();
     StartShell();
+    NotifyLogon();
     return 0;
 }