From ff28695e803876cbf26b24c41dfd8edbbf9c34ae Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Tue, 24 May 2016 21:44:43 +0200 Subject: [PATCH] wxUpdCheckThread::LaunchUpdate() method extended --- UpdCheck/main.cpp | 2 +- Updater/include/Updater/chkthread.h | 5 ++++- Updater/src/chkthread.cpp | 9 ++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/UpdCheck/main.cpp b/UpdCheck/main.cpp index b9f9fa0..80a3deb 100644 --- a/UpdCheck/main.cpp +++ b/UpdCheck/main.cpp @@ -58,7 +58,7 @@ int CALLBACK WinMain(_In_ HINSTANCE hInstance, _In_ HINSTANCE hPrevInstance, _In wxUpdCheckThread worker(locale.GetCanonicalName()); wxUpdCheckThread::wxResult res = worker.CheckForUpdate(); switch (res) { - case wxUpdCheckThread::wxUpdUpdateAvailable: return worker.LaunchUpdate() ? 0 : 1; + case wxUpdCheckThread::wxUpdUpdateAvailable: return worker.LaunchUpdate(NULL, true) ? 0 : 1; case wxUpdCheckThread::wxUpdUpToDate : return 0; default : return res; } diff --git a/Updater/include/Updater/chkthread.h b/Updater/include/Updater/chkthread.h index 8563c99..794b54b 100644 --- a/Updater/include/Updater/chkthread.h +++ b/Updater/include/Updater/chkthread.h @@ -127,11 +127,14 @@ public: /// /// Launches update. /// + /// \param[in] hParent Handle of parent window + /// \param[in] headless Launch silent install + /// /// \returns /// - true if launch succeeded /// - false otherwise /// - bool LaunchUpdate(); + bool LaunchUpdate(WXHWND hParent = NULL, bool headless = false); protected: diff --git a/Updater/src/chkthread.cpp b/Updater/src/chkthread.cpp index c942383..3862db6 100644 --- a/Updater/src/chkthread.cpp +++ b/Updater/src/chkthread.cpp @@ -470,15 +470,14 @@ bool wxUpdCheckThread::DownloadUpdatePackage() } -bool wxUpdCheckThread::LaunchUpdate() +bool wxUpdCheckThread::LaunchUpdate(WXHWND hParent, bool headless) { wxLogStatus(_("Launching update...")); - // Headless Install - wxString param("/qn"); + wxString param(headless ? wxT("/qn ") : wxEmptyString); // Package - param += wxT(" /i \""); + param += wxT("/i \""); param += m_fileName; param += wxT("\""); @@ -490,7 +489,7 @@ bool wxUpdCheckThread::LaunchUpdate() param += fileNameLog; param += wxT("\""); - int result = (int)::ShellExecute(NULL, NULL, wxT("msiexec.exe"), param, NULL, SW_SHOWNORMAL); + int result = (int)::ShellExecute(hParent, NULL, wxT("msiexec.exe"), param, NULL, SW_SHOWNORMAL); if (result > 32) { wxLogStatus(_("msiexec.exe launch succeeded. For detailed information, see %s file."), fileNameLog.c_str()); return true;