diff options
| author | Victor Tran <vicr12345@gmail.com> | 2018-07-13 14:55:07 +1000 |
|---|---|---|
| committer | Victor Tran <vicr12345@gmail.com> | 2018-07-13 14:55:07 +1000 |
| commit | e8ca150c38478cfd4a762dccd3da1752ee19ab29 (patch) | |
| tree | 57038a26154d95206940fadc3e823f8038b70c11 /installer/process/installworker.cpp | |
| parent | abc4021919f406ee25e101122144879f8770d51d (diff) | |
| download | theInstaller-e8ca150c38478cfd4a762dccd3da1752ee19ab29.tar.gz theInstaller-e8ca150c38478cfd4a762dccd3da1752ee19ab29.tar.bz2 theInstaller-e8ca150c38478cfd4a762dccd3da1752ee19ab29.zip | |
Add/Remove Programs support
Diffstat (limited to 'installer/process/installworker.cpp')
| -rw-r--r-- | installer/process/installworker.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/installer/process/installworker.cpp b/installer/process/installworker.cpp index 5b44ad1..e7708ad 100644 --- a/installer/process/installworker.cpp +++ b/installer/process/installworker.cpp @@ -102,6 +102,48 @@ bool InstallWorker::startWork() { dataRoot.insert("global", isGlobalInstall); dataRoot.insert("appurl", url); + //Write uninstall information to registry + QUuid uuid = QUuid::createUuid(); + dataRoot.insert("registryUuid", uuid.toString()); + /*HKEY SoftwareEntry; + HKEY hive; + LPCWSTR keyPath = (LPCWSTR) QString("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + uuid.toString()).utf16(); + + if (isGlobalInstall) { + hive = HKEY_LOCAL_MACHINE; + } else { + hive = HKEY_CURRENT_USER; + } + + LSTATUS createReturn = RegCreateKeyEx(HKEY_LOCAL_MACHINE, keyPath, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &SoftwareEntry, NULL); + if (createReturn == ERROR_SUCCESS) { + RegSetValueEx(SoftwareEntry, TEXT("DisplayName"), 0, REG_SZ, (const BYTE*) vendor.toStdString().data(), vendor.count() + 1); + + RegCloseKey(SoftwareEntry); + + sock->write(QString("DEBUG Uninstall GUID: " + uuid.toString()).toUtf8()); + } else { + sock->write(QString("ALERT " + tr("Error writing uninstall information to the registry: Error 0x%1").arg(QString::number(createReturn, 16)) + "\n").toUtf8()); + }*/ + + QSettings* settings; + if (isGlobalInstall) { + settings = new QSettings("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + uuid.toString(), QSettings::NativeFormat); + } else { + settings = new QSettings("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + uuid.toString(), QSettings::NativeFormat); + } + + settings->setValue("DisplayName", name); + settings->setValue("Publisher", vendor); + settings->setValue("Contact", vendor); + settings->setValue("ModifyPath", dest.absoluteFilePath("uninstall.exe")); + settings->setValue("UninstallString", dest.absoluteFilePath("uninstall.exe")); + settings->setValue("InstallDate", QDateTime::currentDateTime().toString("yyyymmdd")); + settings->setValue("InstallLocation", dest.path()); + settings->setValue("DisplayIcon", executableFile.absoluteFilePath() + ",0"); + settings->sync(); + settings->deleteLater(); + QFile uninstallDataFile(dest.absoluteFilePath("uninstall.json")); uninstallDataFile.open(QFile::WriteOnly); uninstallDataFile.write(QJsonDocument(dataRoot).toJson()); |
