调整更新升级问题
This commit is contained in:
parent
e6b770cd27
commit
716e99f712
|
@ -3606,7 +3606,7 @@ void MainWindow::upgradeApp(QString pkgPath)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QFile::remove(tmpPath + "msvcp140.dll");
|
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::remove(tmpPath + "Qt5Core.dll");
|
||||||
QFile::copy(curPath + "Qt5Core.dll", tmpPath + "Qt5Core.dll");
|
QFile::copy(curPath + "Qt5Core.dll", tmpPath + "Qt5Core.dll");
|
||||||
QFile::remove(tmpPath + "Qt5Gui.dll");
|
QFile::remove(tmpPath + "Qt5Gui.dll");
|
||||||
|
@ -3615,6 +3615,10 @@ void MainWindow::upgradeApp(QString pkgPath)
|
||||||
QFile::copy(curPath + "Qt5Widgets.dll", tmpPath + "Qt5Widgets.dll");
|
QFile::copy(curPath + "Qt5Widgets.dll", tmpPath + "Qt5Widgets.dll");
|
||||||
QFile::remove(tmpPath + "vcruntime140.dll");
|
QFile::remove(tmpPath + "vcruntime140.dll");
|
||||||
QFile::copy(curPath + "vcruntime140.dll", 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;
|
QDir dir;
|
||||||
dir.mkdir(tmpPath + "platforms");
|
dir.mkdir(tmpPath + "platforms");
|
||||||
QFile::remove(tmpPath + "platforms/qwindows.dll");
|
QFile::remove(tmpPath + "platforms/qwindows.dll");
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
@ -80,7 +81,7 @@ int main(int argc, char *argv[])
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QMessageBox msg(QMessageBox::Critical, QObject::tr("error"),
|
QMessageBox msg(QMessageBox::Critical, QObject::tr("error"),
|
||||||
QObject::tr("install failed!"),
|
QObject::tr("install failed!") + "\n" + w.getUpgradeFailInfo(),
|
||||||
QMessageBox::Ok);
|
QMessageBox::Ok);
|
||||||
msg.setButtonText(QMessageBox::Ok, QObject::tr("yes"));
|
msg.setButtonText(QMessageBox::Ok, QObject::tr("yes"));
|
||||||
msg.exec();
|
msg.exec();
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
#include "base/HGDef.h"
|
#include "base/HGDef.h"
|
||||||
#include "base/HGInc.h"
|
#include "base/HGInc.h"
|
||||||
|
#include "base/HGInfo.h"
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QMovie>
|
#include <QMovie>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
@ -50,28 +51,47 @@ bool MainWindow::isInstallSuccess()
|
||||||
return m_success;
|
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;
|
bool ret = false;
|
||||||
|
failInfo.clear();
|
||||||
|
|
||||||
#if defined(HG_CMP_MSC)
|
#if defined(HG_CMP_MSC)
|
||||||
|
|
||||||
PROCESS_INFORMATION ProcessInfo;
|
// PROCESS_INFORMATION ProcessInfo;
|
||||||
STARTUPINFOA StartupInfo;
|
// STARTUPINFOA StartupInfo;
|
||||||
ZeroMemory(&StartupInfo, sizeof(StartupInfo));
|
// ZeroMemory(&StartupInfo, sizeof(StartupInfo));
|
||||||
StartupInfo.cb = sizeof(StartupInfo);
|
// StartupInfo.cb = sizeof(StartupInfo);
|
||||||
|
|
||||||
char command[256];
|
// char command[256];
|
||||||
sprintf(command, "%s %s", pkgPath.c_str(), "/verysilent");
|
// sprintf(command, "%s %s", pkgPath.c_str(), "/verysilent");
|
||||||
if (CreateProcessA(nullptr, command, nullptr, nullptr, FALSE, 0, nullptr, nullptr, &StartupInfo, &ProcessInfo))
|
|
||||||
{
|
SHELLEXECUTEINFOA sei = {0};
|
||||||
WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
|
sei.cbSize = sizeof(SHELLEXECUTEINFOA);
|
||||||
DWORD dwCode = 0;
|
sei.fMask = SEE_MASK_NOCLOSEPROCESS;
|
||||||
GetExitCodeProcess(ProcessInfo.hProcess, &dwCode);
|
sei.nShow = SW_SHOWNORMAL;
|
||||||
CloseHandle(ProcessInfo.hThread);
|
sei.lpFile = pkgPath.c_str();
|
||||||
CloseHandle(ProcessInfo.hProcess);
|
sei.lpParameters = "/verysilent";
|
||||||
ret = (0 == dwCode);
|
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
|
#else
|
||||||
std::string cmd = "pkexec dpkg -i \"" + pkgPath + "\"";
|
std::string cmd = "pkexec dpkg -i \"" + pkgPath + "\"";
|
||||||
|
@ -87,7 +107,7 @@ void HGAPI MainWindow::ThreadFunc(HGThread thread, HGPointer param)
|
||||||
{
|
{
|
||||||
(void)thread;
|
(void)thread;
|
||||||
MainWindow* p = (MainWindow*)param;
|
MainWindow* p = (MainWindow*)param;
|
||||||
p->m_success = Upgrade(p->m_pkgPath);
|
p->m_success = Upgrade(p->m_pkgPath, p->m_upgradeFailInfo);
|
||||||
|
|
||||||
emit p->closeWnd();
|
emit p->closeWnd();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,12 +17,13 @@ public:
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
bool isInstallSuccess();
|
bool isInstallSuccess();
|
||||||
|
QString getUpgradeFailInfo();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void closeWnd();
|
void closeWnd();
|
||||||
|
|
||||||
private:
|
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);
|
static void HGAPI ThreadFunc(HGThread thread, HGPointer param);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -32,5 +33,6 @@ private:
|
||||||
std::string m_pkgPath;
|
std::string m_pkgPath;
|
||||||
HGThread m_thread;
|
HGThread m_thread;
|
||||||
bool m_success;
|
bool m_success;
|
||||||
|
QString m_upgradeFailInfo;
|
||||||
};
|
};
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|
|
@ -25,6 +25,7 @@ TARGET = HGFWUpgradeApp
|
||||||
|
|
||||||
win32 {
|
win32 {
|
||||||
DEFINES += _CRT_SECURE_NO_WARNINGS
|
DEFINES += _CRT_SECURE_NO_WARNINGS
|
||||||
|
QMAKE_LFLAGS += /MANIFESTUAC:"level='requireAdministrator' uiAccess='false'"
|
||||||
LIBS += -ladvapi32 -lpsapi
|
LIBS += -ladvapi32 -lpsapi
|
||||||
|
|
||||||
contains(QT_ARCH, i386) {
|
contains(QT_ARCH, i386) {
|
||||||
|
|
|
@ -25,6 +25,7 @@ TARGET = HGUpgradeApp
|
||||||
|
|
||||||
win32 {
|
win32 {
|
||||||
DEFINES += _CRT_SECURE_NO_WARNINGS
|
DEFINES += _CRT_SECURE_NO_WARNINGS
|
||||||
|
QMAKE_LFLAGS += /MANIFESTUAC:"level='requireAdministrator' uiAccess='false'"
|
||||||
LIBS += -ladvapi32 -lpsapi
|
LIBS += -ladvapi32 -lpsapi
|
||||||
|
|
||||||
contains(QT_ARCH, i386) {
|
contains(QT_ARCH, i386) {
|
||||||
|
|
Loading…
Reference in New Issue