wxUpdCheckThread::LaunchUpdate() method extended

This commit is contained in:
Simon Rozman 2016-05-24 21:44:43 +02:00
parent bf28f7f55e
commit ff28695e80
3 changed files with 9 additions and 7 deletions

View File

@ -58,7 +58,7 @@ int CALLBACK WinMain(_In_ HINSTANCE hInstance, _In_ HINSTANCE hPrevInstance, _In
wxUpdCheckThread worker(locale.GetCanonicalName()); wxUpdCheckThread worker(locale.GetCanonicalName());
wxUpdCheckThread::wxResult res = worker.CheckForUpdate(); wxUpdCheckThread::wxResult res = worker.CheckForUpdate();
switch (res) { 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; case wxUpdCheckThread::wxUpdUpToDate : return 0;
default : return res; default : return res;
} }

View File

@ -127,11 +127,14 @@ public:
/// ///
/// Launches update. /// Launches update.
/// ///
/// \param[in] hParent Handle of parent window
/// \param[in] headless Launch silent install
///
/// \returns /// \returns
/// - true if launch succeeded /// - true if launch succeeded
/// - false otherwise /// - false otherwise
/// ///
bool LaunchUpdate(); bool LaunchUpdate(WXHWND hParent = NULL, bool headless = false);
protected: protected:

View File

@ -470,15 +470,14 @@ bool wxUpdCheckThread::DownloadUpdatePackage()
} }
bool wxUpdCheckThread::LaunchUpdate() bool wxUpdCheckThread::LaunchUpdate(WXHWND hParent, bool headless)
{ {
wxLogStatus(_("Launching update...")); wxLogStatus(_("Launching update..."));
// Headless Install wxString param(headless ? wxT("/qn ") : wxEmptyString);
wxString param("/qn");
// Package // Package
param += wxT(" /i \""); param += wxT("/i \"");
param += m_fileName; param += m_fileName;
param += wxT("\""); param += wxT("\"");
@ -490,7 +489,7 @@ bool wxUpdCheckThread::LaunchUpdate()
param += fileNameLog; param += fileNameLog;
param += wxT("\""); 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) { if (result > 32) {
wxLogStatus(_("msiexec.exe launch succeeded. For detailed information, see %s file."), fileNameLog.c_str()); wxLogStatus(_("msiexec.exe launch succeeded. For detailed information, see %s file."), fileNameLog.c_str());
return true; return true;