diff --git a/app/scanner/mainwindow.cpp b/app/scanner/mainwindow.cpp index 19cc743c..53b66741 100644 --- a/app/scanner/mainwindow.cpp +++ b/app/scanner/mainwindow.cpp @@ -3606,7 +3606,7 @@ void MainWindow::upgradeApp(QString pkgPath) #endif QFile::remove(tmpPath + "msvcp140.dll"); - QFile::copy(curPath + "msvcp140.dll", tmpPath + "msvcp140.dll"); + QFile::copy(curPath + "msvcp140.dll", tmpPath + "msvcp140.dll"); QFile::remove(tmpPath + "Qt5Core.dll"); QFile::copy(curPath + "Qt5Core.dll", tmpPath + "Qt5Core.dll"); QFile::remove(tmpPath + "Qt5Gui.dll"); @@ -3615,6 +3615,10 @@ void MainWindow::upgradeApp(QString pkgPath) QFile::copy(curPath + "Qt5Widgets.dll", tmpPath + "Qt5Widgets.dll"); QFile::remove(tmpPath + "vcruntime140.dll"); QFile::copy(curPath + "vcruntime140.dll", tmpPath + "vcruntime140.dll"); + QFile::remove(tmpPath + "concrt140.dll"); + QFile::copy(curPath + "concrt140.dll", tmpPath + "concrt140.dll"); + QFile::remove(tmpPath + "vcruntime140_1.dll"); + QFile::copy(curPath + "vcruntime140_1.dll", tmpPath + "vcruntime140_1.dll"); QDir dir; dir.mkdir(tmpPath + "platforms"); QFile::remove(tmpPath + "platforms/qwindows.dll"); diff --git a/app/upgrade/main.cpp b/app/upgrade/main.cpp index 4342287b..33351070 100644 --- a/app/upgrade/main.cpp +++ b/app/upgrade/main.cpp @@ -1,3 +1,4 @@ + #include "mainwindow.h" #include @@ -80,7 +81,7 @@ int main(int argc, char *argv[]) else { QMessageBox msg(QMessageBox::Critical, QObject::tr("error"), - QObject::tr("install failed!"), + QObject::tr("install failed!") + "\n" + w.getUpgradeFailInfo(), QMessageBox::Ok); msg.setButtonText(QMessageBox::Ok, QObject::tr("yes")); msg.exec(); diff --git a/app/upgrade/mainwindow.cpp b/app/upgrade/mainwindow.cpp index df030fc1..99d1c017 100644 --- a/app/upgrade/mainwindow.cpp +++ b/app/upgrade/mainwindow.cpp @@ -2,6 +2,7 @@ #include "ui_mainwindow.h" #include "base/HGDef.h" #include "base/HGInc.h" +#include "base/HGInfo.h" #include #include #include @@ -50,28 +51,47 @@ bool MainWindow::isInstallSuccess() return m_success; } -bool MainWindow::Upgrade(const std::string& pkgPath) +QString MainWindow::getUpgradeFailInfo() +{ + return m_upgradeFailInfo; +} + +bool MainWindow::Upgrade(const std::string& pkgPath, QString &failInfo) { bool ret = false; + failInfo.clear(); #if defined(HG_CMP_MSC) - PROCESS_INFORMATION ProcessInfo; - STARTUPINFOA StartupInfo; - ZeroMemory(&StartupInfo, sizeof(StartupInfo)); - StartupInfo.cb = sizeof(StartupInfo); + // PROCESS_INFORMATION ProcessInfo; + // STARTUPINFOA StartupInfo; + // ZeroMemory(&StartupInfo, sizeof(StartupInfo)); + // StartupInfo.cb = sizeof(StartupInfo); - char command[256]; - sprintf(command, "%s %s", pkgPath.c_str(), "/verysilent"); - if (CreateProcessA(nullptr, command, nullptr, nullptr, FALSE, 0, nullptr, nullptr, &StartupInfo, &ProcessInfo)) - { - WaitForSingleObject(ProcessInfo.hProcess, INFINITE); - DWORD dwCode = 0; - GetExitCodeProcess(ProcessInfo.hProcess, &dwCode); - CloseHandle(ProcessInfo.hThread); - CloseHandle(ProcessInfo.hProcess); - ret = (0 == dwCode); - } + // char command[256]; + // sprintf(command, "%s %s", pkgPath.c_str(), "/verysilent"); + + SHELLEXECUTEINFOA sei = {0}; + sei.cbSize = sizeof(SHELLEXECUTEINFOA); + sei.fMask = SEE_MASK_NOCLOSEPROCESS; + sei.nShow = SW_SHOWNORMAL; + sei.lpFile = pkgPath.c_str(); + sei.lpParameters = "/verysilent"; + sei.lpVerb = "runas"; + + // if (CreateProcessA(nullptr, command, nullptr, nullptr, FALSE, 0, nullptr, nullptr, &StartupInfo, &ProcessInfo)) + if (ShellExecuteExA(&sei)) + { + WaitForSingleObject(sei.hProcess, INFINITE); + DWORD dwCode = 0; + GetExitCodeProcess(sei.hProcess, &dwCode); + + failInfo = QString("ExitCode=%1").arg((int)dwCode); + + //CloseHandle(ProcessInfo.hThread); + CloseHandle(sei.hProcess); + ret = (0 == dwCode); + } #else std::string cmd = "pkexec dpkg -i \"" + pkgPath + "\""; @@ -87,7 +107,7 @@ void HGAPI MainWindow::ThreadFunc(HGThread thread, HGPointer param) { (void)thread; MainWindow* p = (MainWindow*)param; - p->m_success = Upgrade(p->m_pkgPath); + p->m_success = Upgrade(p->m_pkgPath, p->m_upgradeFailInfo); emit p->closeWnd(); } diff --git a/app/upgrade/mainwindow.h b/app/upgrade/mainwindow.h index c0d53d37..07c73e7a 100644 --- a/app/upgrade/mainwindow.h +++ b/app/upgrade/mainwindow.h @@ -17,12 +17,13 @@ public: ~MainWindow(); bool isInstallSuccess(); + QString getUpgradeFailInfo(); signals: void closeWnd(); private: - static bool Upgrade(const std::string& pkgPath); + static bool Upgrade(const std::string& pkgPath, QString &failInfo); static void HGAPI ThreadFunc(HGThread thread, HGPointer param); private: @@ -32,5 +33,6 @@ private: std::string m_pkgPath; HGThread m_thread; bool m_success; + QString m_upgradeFailInfo; }; #endif // MAINWINDOW_H diff --git a/build-qt/HGSolution/HGFWUpgrade/HGFWUpgrade.pro b/build-qt/HGSolution/HGFWUpgrade/HGFWUpgrade.pro index 79d95534..4727258d 100644 --- a/build-qt/HGSolution/HGFWUpgrade/HGFWUpgrade.pro +++ b/build-qt/HGSolution/HGFWUpgrade/HGFWUpgrade.pro @@ -25,6 +25,7 @@ TARGET = HGFWUpgradeApp win32 { DEFINES += _CRT_SECURE_NO_WARNINGS + QMAKE_LFLAGS += /MANIFESTUAC:"level='requireAdministrator' uiAccess='false'" LIBS += -ladvapi32 -lpsapi contains(QT_ARCH, i386) { diff --git a/build-qt/HGSolution/HGUpgrade/HGUpgrade.pro b/build-qt/HGSolution/HGUpgrade/HGUpgrade.pro index ea281846..1bf0514f 100644 --- a/build-qt/HGSolution/HGUpgrade/HGUpgrade.pro +++ b/build-qt/HGSolution/HGUpgrade/HGUpgrade.pro @@ -25,6 +25,7 @@ TARGET = HGUpgradeApp win32 { DEFINES += _CRT_SECURE_NO_WARNINGS + QMAKE_LFLAGS += /MANIFESTUAC:"level='requireAdministrator' uiAccess='false'" LIBS += -ladvapi32 -lpsapi contains(QT_ARCH, i386) {