From f76929f0359efc2a336f2e6823a750f4ce7f0bf9 Mon Sep 17 00:00:00 2001 From: DavidXanatos Date: Sun, 15 May 2022 13:26:22 +0200 Subject: [PATCH] 1.0.22 --- SandboxiePlus/SandMan/SandMan.cpp | 9 ++++- .../SandMan/Windows/SettingsWindow.cpp | 37 ++++++++++++++++++- .../SandMan/Windows/SettingsWindow.h | 2 + 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/SandboxiePlus/SandMan/SandMan.cpp b/SandboxiePlus/SandMan/SandMan.cpp index e7a0fb09..594d625c 100644 --- a/SandboxiePlus/SandMan/SandMan.cpp +++ b/SandboxiePlus/SandMan/SandMan.cpp @@ -1716,9 +1716,16 @@ void CSandMan::OnMaintenance() Status = CSbieUtils::Uninstall(CSbieUtils::eService); // uninstall - else if (sender() == m_pUninstallAll) + else if (sender() == m_pUninstallAll) { + Status = StopSbie(true); + AutorunEnable(false); + + CSettingsWindow__RemoveContextMenu(); + CSbieUtils::RemoveContextMenu2(); + } + HandleMaintenance(Status); } diff --git a/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp b/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp index a6dae463..27d66e1c 100644 --- a/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp +++ b/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp @@ -215,6 +215,12 @@ void CSettingsWindow::closeEvent(QCloseEvent *e) Qt::CheckState CSettingsWindow__IsContextMenu() { + QSettings settings("HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\PackagedCom\\Package", QSettings::NativeFormat); + foreach(const QString & Key, settings.childGroups()) { + if (Key.indexOf("SandboxieShell") == 0) + return Qt::Checked; + } + QString cmd = CSbieUtils::GetContextMenuStartCmd(); if (cmd.contains("SandMan.exe", Qt::CaseInsensitive)) return Qt::Checked; // set up and sandman @@ -225,11 +231,40 @@ Qt::CheckState CSettingsWindow__IsContextMenu() void CSettingsWindow__AddContextMenu() { + QSettings settings("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", QSettings::NativeFormat); + if (settings.value("CurrentBuild") >= 22000) // Windows 11 + { + QProcess Proc; + Proc.execute("rundll32.exe", QStringList() << QCoreApplication::applicationDirPath().replace("/", "\\") + "\\SbieShellExt.dll,RegisterPackage"); + Proc.waitForFinished(); + return; + } + CSbieUtils::AddContextMenu(QApplication::applicationDirPath().replace("/", "\\") + "\\SandMan.exe", CSettingsWindow::tr("Run &Sandboxed"), //CSettingsWindow::tr("Explore &Sandboxed"), QApplication::applicationDirPath().replace("/", "\\") + "\\Start.exe"); } +void CSettingsWindow__RemoveContextMenu() +{ + QSettings settings("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", QSettings::NativeFormat); + if (settings.value("CurrentBuild") >= 22000) // Windows 11 + { + QProcess Proc; + Proc.execute("rundll32.exe", QStringList() << QCoreApplication::applicationDirPath().replace("/", "\\") + "\\SbieShellExt.dll,RemovePackage"); + Proc.waitForFinished(); + } + + CSbieUtils::RemoveContextMenu(); +} + +void CSettingsWindow__AddBrowserIcon() +{ + QString Path = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation).replace("/", "\\"); + Path += "\\" + CSettingsWindow::tr("Sandboxed Web Browser") + ".lnk"; + CSbieUtils::CreateShortcut(theAPI, Path, "", "", "default_browser"); +} + void CSettingsWindow::LoadSettings() { ui.uiLang->setCurrentIndex(ui.uiLang->findData(theConf->GetString("Options/UiLanguage"))); @@ -398,7 +433,7 @@ void CSettingsWindow::SaveSettings() if (ui.chkShellMenu->isChecked()) CSettingsWindow__AddContextMenu(); else - CSbieUtils::RemoveContextMenu(); + CSettingsWindow__RemoveContextMenu(); } if (ui.chkShellMenu2->isChecked() != CSbieUtils::HasContextMenu2()) { diff --git a/SandboxiePlus/SandMan/Windows/SettingsWindow.h b/SandboxiePlus/SandMan/Windows/SettingsWindow.h index 7377fab3..bca2b341 100644 --- a/SandboxiePlus/SandMan/Windows/SettingsWindow.h +++ b/SandboxiePlus/SandMan/Windows/SettingsWindow.h @@ -88,6 +88,8 @@ private: }; void CSettingsWindow__AddContextMenu(); +void CSettingsWindow__RemoveContextMenu(); +void CSettingsWindow__AddBrowserIcon(); void WindowsMoveFile(const QString& from, const QString& to);