From 0589a251c13133dcea38254e09d15aa91885efaa Mon Sep 17 00:00:00 2001 From: Amrsatrio Date: Wed, 13 Mar 2024 07:18:48 +0700 Subject: [PATCH] Setup: Moved uninstallation prompt dialog existence check to the GUI --- ep_gui/GUI.c | 32 ++++++++++++++++++++------------ ep_setup/ep_setup.c | 7 ------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/ep_gui/GUI.c b/ep_gui/GUI.c index da3b075..4a08a60 100644 --- a/ep_gui/GUI.c +++ b/ep_gui/GUI.c @@ -2184,19 +2184,27 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt) } else if (!strncmp(line + 1, "uninstall", 6)) { - wchar_t uninstallLink[MAX_PATH]; - ZeroMemory(uninstallLink, sizeof(uninstallLink)); - SHGetFolderPathW(NULL, SPECIAL_FOLDER, NULL, SHGFP_TYPE_CURRENT, uninstallLink); - wcscat_s(uninstallLink, MAX_PATH, _T(APP_RELATIVE_PATH) L"\\" _T(SETUP_UTILITY_NAME)); + HWND hwndExistingMb = FindWindowExW(NULL, NULL, L"#32770", _T(PRODUCT_NAME)); + if (hwndExistingMb) + { + SwitchToThisWindow(hwndExistingMb, TRUE); + } + else + { + wchar_t uninstallLink[MAX_PATH]; + ZeroMemory(uninstallLink, sizeof(uninstallLink)); + SHGetFolderPathW(NULL, SPECIAL_FOLDER, NULL, SHGFP_TYPE_CURRENT, uninstallLink); + wcscat_s(uninstallLink, MAX_PATH, _T(APP_RELATIVE_PATH) L"\\" _T(SETUP_UTILITY_NAME)); - SHELLEXECUTEINFOW sei; - ZeroMemory(&sei, sizeof(SHELLEXECUTEINFOW)); - sei.cbSize = sizeof(sei); - sei.hwnd = hwnd; - sei.lpFile = uninstallLink; - sei.nShow = SW_NORMAL; - sei.lpParameters = L"/uninstall"; - ShellExecuteExW(&sei); + SHELLEXECUTEINFOW sei; + ZeroMemory(&sei, sizeof(SHELLEXECUTEINFOW)); + sei.cbSize = sizeof(sei); + sei.hwnd = hwnd; + sei.lpFile = uninstallLink; + sei.nShow = SW_NORMAL; + sei.lpParameters = L"/uninstall"; + ShellExecuteExW(&sei); + } } else if (!strncmp(line + 1, "update_weather", 14)) { diff --git a/ep_setup/ep_setup.c b/ep_setup/ep_setup.c index 66eabfb..2586c82 100644 --- a/ep_setup/ep_setup.c +++ b/ep_setup/ep_setup.c @@ -517,13 +517,6 @@ int WINAPI wWinMain( bIsUpdate = (argc >= 1 && !_wcsicmp(wargv[0], L"/update_silent")); if (!bInstall && (!_wcsicmp(wargv[0], L"/uninstall") || bForcePromptForUninstall)) { - HWND hwndExistingMb = FindWindowExW(NULL, NULL, L"#32770", _T(PRODUCT_NAME)); - if (hwndExistingMb) - { - SwitchToThisWindow(hwndExistingMb, TRUE); - exit(0); - } - wchar_t mbText[256]; mbText[0] = 0; LoadStringW(hInstance, IDS_SETUP_UNINSTALL_PROMPT, mbText, ARRAYSIZE(mbText));