Author: tfaber Date: Tue Sep 11 17:08:38 2012 New Revision: 57277
URL: http://svn.reactos.org/svn/reactos?rev=57277&view=rev Log: [SYSSETUP] - 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 ;)
Modified: trunk/reactos/dll/win32/syssetup/wizard.c
Modified: trunk/reactos/dll/win32/syssetup/wizard.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/syssetup/wizard.c... ============================================================================== --- trunk/reactos/dll/win32/syssetup/wizard.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/syssetup/wizard.c [iso-8859-1] Tue Sep 11 17:08:38 2012 @@ -786,33 +786,45 @@
static BOOL -RunControlPanelApplet(HWND hwnd, WCHAR *lpCommandLine) -{ - STARTUPINFOW StartupInfo; - PROCESS_INFORMATION ProcessInformation; - - ZeroMemory(&StartupInfo, sizeof(STARTUPINFOW)); - StartupInfo.cb = sizeof(STARTUPINFOW); - - if (!CreateProcessW(NULL, - lpCommandLine, - NULL, - NULL, - FALSE, - 0, - NULL, - NULL, - &StartupInfo, - &ProcessInformation)) - { - MessageBoxW(hwnd, L"Error: failed to launch rundll32", NULL, MB_ICONERROR); +RunControlPanelApplet(HWND hwnd, PCWSTR pwszCPLParameters) +{ + 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); + + 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 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 @@ 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 @@ 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, wszBuf); + { + RunControlPanelApplet(hwndDlg, L"intl.cpl,,/f:"unattend.inf""); + } + SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, IDD_DATETIMEPAGE); return TRUE; }