调整更新升级问题
This commit is contained in:
parent
e6b770cd27
commit
716e99f712
|
@ -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");
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
@ -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();
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "ui_mainwindow.h"
|
||||
#include "base/HGDef.h"
|
||||
#include "base/HGInc.h"
|
||||
#include "base/HGInfo.h"
|
||||
#include <QLabel>
|
||||
#include <QMovie>
|
||||
#include <QMessageBox>
|
||||
|
@ -50,26 +51,45 @@ 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))
|
||||
// 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(ProcessInfo.hProcess, INFINITE);
|
||||
WaitForSingleObject(sei.hProcess, INFINITE);
|
||||
DWORD dwCode = 0;
|
||||
GetExitCodeProcess(ProcessInfo.hProcess, &dwCode);
|
||||
CloseHandle(ProcessInfo.hThread);
|
||||
CloseHandle(ProcessInfo.hProcess);
|
||||
GetExitCodeProcess(sei.hProcess, &dwCode);
|
||||
|
||||
failInfo = QString("ExitCode=%1").arg((int)dwCode);
|
||||
|
||||
//CloseHandle(ProcessInfo.hThread);
|
||||
CloseHandle(sei.hProcess);
|
||||
ret = (0 == dwCode);
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue