From a78186f50222e3bae7a38b78a3ac3d7f7352a1e8 Mon Sep 17 00:00:00 2001 From: Adrien Lamarque Date: Fri, 14 Oct 2016 23:36:22 +0200 Subject: [PATCH] Fix for slow startup under certain conditions (#1122) Fixes #1122 by simply calling CreateProcess before the SendMessageTimeout calls that are used to propagate environment variable changes. --- launcher/src/CmderLauncher.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/launcher/src/CmderLauncher.cpp b/launcher/src/CmderLauncher.cpp index 24f35c8..acfd6eb 100644 --- a/launcher/src/CmderLauncher.cpp +++ b/launcher/src/CmderLauncher.cpp @@ -169,8 +169,7 @@ void StartCmder(std::wstring path, bool is_single_mode) } } // Ensure EnvironmentVariables are propagated. - SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM)"Environment", SMTO_ABORTIFHUNG, 5000, NULL); - SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM) L"Environment", SMTO_ABORTIFHUNG, 5000, NULL); // For Windows >= 8 + STARTUPINFO si = { 0 }; si.cb = sizeof(STARTUPINFO); @@ -178,12 +177,15 @@ void StartCmder(std::wstring path, bool is_single_mode) si.lpTitle = appId; si.dwFlags = STARTF_TITLEISAPPID; #endif - PROCESS_INFORMATION pi; if (!CreateProcess(conEmuPath, args, NULL, NULL, false, 0, NULL, NULL, &si, &pi)) { MessageBox(NULL, _T("Unable to create the ConEmu Process!"), _T("Error"), MB_OK); return; } + + LRESULT lr = SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM)"Environment", SMTO_ABORTIFHUNG | SMTO_NOTIMEOUTIFNOTHUNG, 5000, NULL); + lr = SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM) L"Environment", SMTO_ABORTIFHUNG | SMTO_NOTIMEOUTIFNOTHUNG, 5000, NULL); // For Windows >= 8 + } bool IsUserOnly(std::wstring opt)