static DWORD pExecuteUpgradeMsi(LPTSTR szUpgradeMsi) { DBGPRT_INFO(_FT("Running update package from --> %s\n"), szUpgradeMsi); DWORD dwResult = 0; // build up CreateProcess structures STARTUPINFO sui = {0}; PROCESS_INFORMATION pi = {0}; sui.cb = sizeof(STARTUPINFO); sui.dwFlags = STARTF_USESHOWWINDOW; sui.wShowWindow = SW_SHOW; // // build command line and specify delayreboot option to Update // three acounts for terminating null plus quotes for module // DWORD cchCommandLine = lstrlen(szUpgradeMsi) + lstrlen(MSI_DELAY_REBOOT_QUIET) + 3; TCHAR *szCommandLine = new TCHAR[cchCommandLine]; if (!szCommandLine) { return ERROR_OUTOFMEMORY; } if (FAILED(StringCchCopy(szCommandLine, cchCommandLine, _T("\""))) || FAILED(StringCchCat(szCommandLine, cchCommandLine, szUpgradeMsi)) || FAILED(StringCchCat(szCommandLine, cchCommandLine, _T("\""))) || FAILED(StringCchCat(szCommandLine, cchCommandLine, MSI_DELAY_REBOOT_QUIET))) { delete [] szCommandLine; return ERROR_INSTALL_FAILURE; } // // run update process // BOOL fSuccess = ::CreateProcess( NULL, szCommandLine, NULL, NULL, FALSE, CREATE_DEFAULT_ERROR_MODE, NULL, NULL, &sui, &pi); if(!fSuccess) { // failed to launch. dwResult = ::GetLastError(); delete [] szCommandLine; return dwResult; } dwResult = WaitForHandle(pi.hProcess); if(ERROR_SUCCESS != dwResult) { delete [] szCommandLine; return dwResult; } DWORD dwExitCode = 0; ::GetExitCodeProcess(pi.hProcess, &dwExitCode); ::CloseHandle(pi.hProcess); delete [] szCommandLine; return dwExitCode; }
DWORD CSetupTask::WaitForStop(DWORD dwWaitTimeout) { return WaitForHandle(m_hThread, dwWaitTimeout); // return ::WaitForSingleObject(m_hThread, dwWaitTimeout); }