[SYSSETUP]
authorThomas Faber <thomas.faber@reactos.org>
Tue, 11 Sep 2012 17:08:38 +0000 (17:08 +0000)
committerThomas Faber <thomas.faber@reactos.org>
Tue, 11 Sep 2012 17:08:38 +0000 (17:08 +0000)
- Use a writable buffer for lpCommandLine in CreateProcessW. Simplify starting of control panel applets. Patch by Hermès Bélusca.
- CORE-6570 #resolve #comment We need FishEye ;)

svn path=/trunk/; revision=57277

reactos/dll/win32/syssetup/wizard.c

index 8bac2d8..2ec3352 100644 (file)
@@ -786,33 +786,45 @@ SetKeyboardLayoutName(HWND hwnd)
 
 
 static BOOL
-RunControlPanelApplet(HWND hwnd, WCHAR *lpCommandLine)
+RunControlPanelApplet(HWND hwnd, PCWSTR pwszCPLParameters)
 {
-    STARTUPINFOW StartupInfo;
-    PROCESS_INFORMATION ProcessInformation;
+    if (pwszCPLParameters)
+    {
+        STARTUPINFOW StartupInfo;
+        PROCESS_INFORMATION ProcessInformation;
+        WCHAR CmdLine[MAX_PATH] = L"rundll32.exe shell32.dll,Control_RunDLL ";
 
-    ZeroMemory(&StartupInfo, sizeof(STARTUPINFOW));
-    StartupInfo.cb = sizeof(STARTUPINFOW);
+        ZeroMemory(&StartupInfo, sizeof(STARTUPINFOW));
+        StartupInfo.cb = sizeof(STARTUPINFOW);
 
-    if (!CreateProcessW(NULL,
-                        lpCommandLine,
-                        NULL,
-                        NULL,
-                        FALSE,
-                        0,
-                        NULL,
-                        NULL,
-                        &StartupInfo,
-                        &ProcessInformation))
+        ASSERT(_countof(CmdLine) > wcslen(CmdLine) + wcslen(pwszCPLParameters));
+        wcscat(CmdLine, pwszCPLParameters);
+
+        if (!CreateProcessW(NULL,
+                            CmdLine,
+                            NULL,
+                            NULL,
+                            FALSE,
+                            0,
+                            NULL,
+                            NULL,
+                            &StartupInfo,
+                            &ProcessInformation))
+        {
+            MessageBoxW(hwnd, L"Error: Failed to launch the Control Panel Applet.", NULL, MB_ICONERROR);
+            return FALSE;
+        }
+
+        WaitForSingleObject(ProcessInformation.hProcess, INFINITE);
+        CloseHandle(ProcessInformation.hThread);
+        CloseHandle(ProcessInformation.hProcess);
+        return TRUE;
+    }
+    else
     {
-        MessageBoxW(hwnd, L"Error: failed to launch rundll32", NULL, MB_ICONERROR);
+        MessageBoxW(hwnd, L"Error: Failed to launch the Control Panel Applet.", NULL, MB_ICONERROR);
         return FALSE;
     }
-
-    WaitForSingleObject(ProcessInformation.hProcess, INFINITE);
-    CloseHandle(ProcessInformation.hThread);
-    CloseHandle(ProcessInformation.hProcess);
-    return TRUE;
 }
 
 static VOID
@@ -866,12 +878,12 @@ LocalePageDlgProc(HWND hwndDlg,
                 switch (LOWORD(wParam))
                 {
                     case IDC_CUSTOMLOCALE:
-                        RunControlPanelApplet(hwndDlg, L"rundll32.exe shell32.dll,Control_RunDLL intl.cpl,,5");
+                        RunControlPanelApplet(hwndDlg, L"intl.cpl,,5");
                         /* FIXME: Update input locale name */
                         break;
 
                     case IDC_CUSTOMLAYOUT:
-                        RunControlPanelApplet(hwndDlg, L"rundll32.exe shell32.dll,Control_RunDLL input.dll,@1");
+                        RunControlPanelApplet(hwndDlg, L"input.dll,@1");
                         break;
                 }
             }
@@ -888,13 +900,18 @@ LocalePageDlgProc(HWND hwndDlg,
                     PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
                     if (SetupData->UnattendSetup)
                     {
-                        WCHAR wszPath[MAX_PATH], wszBuf[1024];
+                        WCHAR wszPath[MAX_PATH];
                         if (GetRosInstallCD(wszPath, _countof(wszPath)))
-                            swprintf(wszBuf, L"rundll32.exe shell32.dll,Control_RunDLL intl.cpl,,/f:\"%sreactos\\unattend.inf\"", wszPath);
+                        {
+                            WCHAR wszParams[1024];
+                            swprintf(wszParams, L"intl.cpl,,/f:\"%sreactos\\unattend.inf\"", wszPath);
+                            RunControlPanelApplet(hwndDlg, wszParams);
+                        }
                         else
-                            wcscpy(wszBuf, L"rundll32.exe shell32.dll,Control_RunDLL intl.cpl,,/f:\"unattend.inf\"");
+                        {
+                            RunControlPanelApplet(hwndDlg, L"intl.cpl,,/f:\"unattend.inf\"");
+                        }
 
-                        RunControlPanelApplet(hwndDlg, wszBuf);
                         SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, IDD_DATETIMEPAGE);
                         return TRUE;
                     }