From f3f8d41dd6ba6c6916e556ed6b3966e1ccbde122 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 17 Jul 2025 17:22:36 +0000 Subject: [PATCH 1/4] Initial plan From 3b0f40eb92f86904ea57b7522f95e36cbf51d872 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 17 Jul 2025 17:32:24 +0000 Subject: [PATCH 2/4] Refactor context menu functions to eliminate code duplication Co-authored-by: offhub <6871698+offhub@users.noreply.github.com> --- SandboxiePlus/QSbieAPI/SbieUtils.cpp | 154 ++++++++++++--------------- SandboxiePlus/QSbieAPI/SbieUtils.h | 3 + 2 files changed, 74 insertions(+), 83 deletions(-) diff --git a/SandboxiePlus/QSbieAPI/SbieUtils.cpp b/SandboxiePlus/QSbieAPI/SbieUtils.cpp index ad63d2ddd9d..cc285ba7e14 100644 --- a/SandboxiePlus/QSbieAPI/SbieUtils.cpp +++ b/SandboxiePlus/QSbieAPI/SbieUtils.cpp @@ -399,37 +399,55 @@ QString CSbieUtils::GetContextMenuStartCmd() return QString::fromWCharArray(path); } -void CSbieUtils::AddContextMenu(const QString& StartPath, const QString& RunStr, /*const QString& ExploreStr,*/ const QString& IconPath) +void CSbieUtils::AddContextMenuHelper(const QString& StartPath, const QString& RunStr, const QString& IconPath, const QString& shellKey, const QString& command, bool forFiles, bool forFolders, const QString& iconSuffix) { std::wstring start_path = L"\"" + StartPath.toStdWString() + L"\""; - std::wstring icon_path = L"\"" + (IconPath.isEmpty() ? StartPath : IconPath).toStdWString() + L"\""; - - CreateShellEntry(L"*", L"sandbox", RunStr.toStdWString(), icon_path, start_path + L" /box:__ask__ \"%1\" %*"); + std::wstring icon_path = L"\"" + (IconPath.isEmpty() ? StartPath : IconPath).toStdWString() + L"\"" + iconSuffix.toStdWString(); - std::wstring explorer_path(512, L'\0'); - - HKEY hkeyWinlogon; - LONG rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"software\\microsoft\\windows nt\\currentversion\\winlogon", 0, KEY_READ, &hkeyWinlogon); - if (rc == 0) - { - ULONG path_len = explorer_path.size() * sizeof(WCHAR); - ULONG type; - rc = RegQueryValueExW(hkeyWinlogon, L"Shell", NULL, &type, (BYTE *)explorer_path.c_str(), &path_len); - if (rc == 0 && (type == REG_SZ || type == REG_EXPAND_SZ)) - explorer_path.resize(path_len / sizeof(WCHAR)); - RegCloseKey(hkeyWinlogon); + if (forFiles) { + CreateShellEntry(L"*", shellKey.toStdWString(), RunStr.toStdWString(), icon_path, start_path + L" " + command.toStdWString() + L" \"%1\" %*"); } - // get default explorer path - if (*explorer_path.c_str() == L'\0' || _wcsicmp(explorer_path.c_str(), L"explorer.exe") == 0) - { - GetWindowsDirectoryW((wchar_t*)explorer_path.c_str(), MAX_PATH); - ULONG path_len = wcslen(explorer_path.c_str()); - explorer_path.resize(path_len); - explorer_path.append(L"\\explorer.exe"); + if (forFolders) { + std::wstring folder_command = start_path + L" " + command.toStdWString() + L" "; + + // Special handling for the original sandbox context menu + if (shellKey == "sandbox") { + std::wstring explorer_path(512, L'\0'); + + HKEY hkeyWinlogon; + LONG rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"software\\microsoft\\windows nt\\currentversion\\winlogon", 0, KEY_READ, &hkeyWinlogon); + if (rc == 0) + { + ULONG path_len = explorer_path.size() * sizeof(WCHAR); + ULONG type; + rc = RegQueryValueExW(hkeyWinlogon, L"Shell", NULL, &type, (BYTE *)explorer_path.c_str(), &path_len); + if (rc == 0 && (type == REG_SZ || type == REG_EXPAND_SZ)) + explorer_path.resize(path_len / sizeof(WCHAR)); + RegCloseKey(hkeyWinlogon); + } + + // get default explorer path + if (*explorer_path.c_str() == L'\0' || _wcsicmp(explorer_path.c_str(), L"explorer.exe") == 0) + { + GetWindowsDirectoryW((wchar_t*)explorer_path.c_str(), MAX_PATH); + ULONG path_len = wcslen(explorer_path.c_str()); + explorer_path.resize(path_len); + explorer_path.append(L"\\explorer.exe"); + } + + folder_command += explorer_path + L" \"%1\""; + } else { + folder_command += L"\"%1\" %*"; + } + + CreateShellEntry(L"Folder", shellKey.toStdWString(), RunStr.toStdWString(), icon_path, folder_command); } +} - CreateShellEntry(L"Folder", L"sandbox", RunStr.toStdWString(), icon_path, start_path + L" /box:__ask__ " + explorer_path + L" \"%1\""); // ExploreStr +void CSbieUtils::AddContextMenu(const QString& StartPath, const QString& RunStr, /*const QString& ExploreStr,*/ const QString& IconPath) +{ + AddContextMenuHelper(StartPath, RunStr, IconPath, "sandbox", "/box:__ask__", true, true); } void CSbieUtils::CreateShellEntry(const std::wstring& classname, const std::wstring& key, const std::wstring& cmdtext, const std::wstring& iconpath, const std::wstring& startcmd) @@ -455,109 +473,79 @@ void CSbieUtils::CreateShellEntry(const std::wstring& classname, const std::wstr RegCloseKey(hkey); } +void CSbieUtils::RemoveContextMenuHelper(const QString& shellKey, bool forFiles, bool forFolders) +{ + if (forFiles) { + std::wstring key = L"software\\classes\\*\\shell\\" + shellKey.toStdWString(); + RegDeleteTreeW(HKEY_CURRENT_USER, key.c_str()); + } + if (forFolders) { + std::wstring key = L"software\\classes\\folder\\shell\\" + shellKey.toStdWString(); + RegDeleteTreeW(HKEY_CURRENT_USER, key.c_str()); + } +} + void CSbieUtils::RemoveContextMenu() { - RegDeleteTreeW(HKEY_CURRENT_USER, L"software\\classes\\*\\shell\\sandbox"); - RegDeleteTreeW(HKEY_CURRENT_USER, L"software\\classes\\folder\\shell\\sandbox"); + RemoveContextMenuHelper("sandbox", true, true); } -bool CSbieUtils::HasContextMenu2() +bool CSbieUtils::HasContextMenuHelper(const QString& shellKey) { - const wchar_t* key = L"Software\\Classes\\*\\shell\\unbox\\command"; + std::wstring key = L"Software\\Classes\\*\\shell\\" + shellKey.toStdWString() + L"\\command"; HKEY hkey; - LONG rc = RegOpenKeyExW(HKEY_CURRENT_USER, key, 0, KEY_READ, &hkey); + LONG rc = RegOpenKeyExW(HKEY_CURRENT_USER, key.c_str(), 0, KEY_READ, &hkey); if (rc != 0) return false; RegCloseKey(hkey); - return true; } -void CSbieUtils::AddContextMenu2(const QString& StartPath, const QString& RunStr, const QString& IconPath) +bool CSbieUtils::HasContextMenu2() { - std::wstring start_path = L"\"" + StartPath.toStdWString() + L"\""; - std::wstring icon_path = L"\"" + (IconPath.isEmpty() ? StartPath : IconPath).toStdWString() + L"\",-104"; + return HasContextMenuHelper("unbox"); +} - CreateShellEntry(L"*", L"unbox", RunStr.toStdWString(), icon_path, start_path + L" /disable_force \"%1\" %*"); +void CSbieUtils::AddContextMenu2(const QString& StartPath, const QString& RunStr, const QString& IconPath) +{ + AddContextMenuHelper(StartPath, RunStr, IconPath, "unbox", "/disable_force", true, false, ",-104"); } void CSbieUtils::RemoveContextMenu2() { - RegDeleteTreeW(HKEY_CURRENT_USER, L"software\\classes\\*\\shell\\unbox"); + RemoveContextMenuHelper("unbox", true, false); } bool CSbieUtils::HasContextMenu3() { - const wchar_t* key = L"Software\\Classes\\*\\shell\\addforce\\command"; - //const wchar_t* key2 = L"Software\\Classes\\*\\Folder\\addforce\\command"; - HKEY hkey,hKey2; - LONG rc = RegOpenKeyExW(HKEY_CURRENT_USER, key, 0, KEY_READ, &hkey); - if (rc != 0) - return false; - - RegCloseKey(hkey); - - - /*rc = RegOpenKeyEx(HKEY_CURRENT_USER, key2, 0, KEY_READ, &hkey2); - if (rc != 0) - return false; - - RegCloseKey(hkey2);*/ - - return true; + return HasContextMenuHelper("addforce"); } void CSbieUtils::AddContextMenu3(const QString& StartPath, const QString& RunStr, const QString& IconPath) { - std::wstring start_path = L"\"" + StartPath.toStdWString() + L"\""; - std::wstring icon_path = L"\"" + (IconPath.isEmpty() ? StartPath : IconPath).toStdWString() + L"\""; - - CreateShellEntry(L"*", L"addforce", RunStr.toStdWString(), icon_path, start_path + L" /add_force \"%1\" %*"); - CreateShellEntry(L"Folder", L"addforce", RunStr.toStdWString(), icon_path, start_path + L" /add_force \"%1\" %*"); + AddContextMenuHelper(StartPath, RunStr, IconPath, "addforce", "/add_force", true, true); } void CSbieUtils::RemoveContextMenu3() { - RegDeleteTreeW(HKEY_CURRENT_USER, L"software\\classes\\*\\shell\\addforce"); - RegDeleteTreeW(HKEY_CURRENT_USER, L"software\\classes\\folder\\shell\\addforce"); + RemoveContextMenuHelper("addforce", true, true); } bool CSbieUtils::HasContextMenu4() { - const wchar_t* key = L"Software\\Classes\\*\\shell\\addopen\\command"; - //const wchar_t* key2 = L"Software\\Classes\\*\\Folder\\addforce\\command"; - HKEY hkey, hKey2; - LONG rc = RegOpenKeyExW(HKEY_CURRENT_USER, key, 0, KEY_READ, &hkey); - if (rc != 0) - return false; - - RegCloseKey(hkey); - - - /*rc = RegOpenKeyEx(HKEY_CURRENT_USER, key2, 0, KEY_READ, &hkey2); - if (rc != 0) - return false; - - RegCloseKey(hkey2);*/ - - return true; + return HasContextMenuHelper("addopen"); } void CSbieUtils::AddContextMenu4(const QString& StartPath, const QString& RunStr, const QString& IconPath) { - std::wstring start_path = L"\"" + StartPath.toStdWString() + L"\""; - std::wstring icon_path = L"\"" + (IconPath.isEmpty() ? StartPath : IconPath).toStdWString() + L"\""; - - CreateShellEntry(L"*", L"addopen", RunStr.toStdWString(), icon_path, start_path + L" /add_open \"%1\" %*"); - CreateShellEntry(L"Folder", L"addopen", RunStr.toStdWString(), icon_path, start_path + L" /add_open \"%1\" %*"); + AddContextMenuHelper(StartPath, RunStr, IconPath, "addopen", "/add_open", true, true); } void CSbieUtils::RemoveContextMenu4() { - RegDeleteTreeW(HKEY_CURRENT_USER, L"software\\classes\\*\\shell\\addopen"); - RegDeleteTreeW(HKEY_CURRENT_USER, L"software\\classes\\folder\\shell\\addopen"); + RemoveContextMenuHelper("addopen", true, true); } ////////////////////////////////////////////////////////////////////////////// diff --git a/SandboxiePlus/QSbieAPI/SbieUtils.h b/SandboxiePlus/QSbieAPI/SbieUtils.h index 7fa440012f4..50400c0c76d 100644 --- a/SandboxiePlus/QSbieAPI/SbieUtils.h +++ b/SandboxiePlus/QSbieAPI/SbieUtils.h @@ -63,6 +63,9 @@ class QSBIEAPI_EXPORT CSbieUtils static void Uninstall(EComponent Component, QStringList& Ops); static void CreateShellEntry(const std::wstring& classname, const std::wstring& key, const std::wstring& cmdtext, const std::wstring& iconpath, const std::wstring& startcmd); + static void AddContextMenuHelper(const QString& StartPath, const QString& RunStr, const QString& IconPath, const QString& shellKey, const QString& command, bool forFiles, bool forFolders, const QString& iconSuffix = QString()); + static bool HasContextMenuHelper(const QString& shellKey); + static void RemoveContextMenuHelper(const QString& shellKey, bool forFiles, bool forFolders); }; From a273a233c68c11c363352be7471a05fbba50a251 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 17 Jul 2025 17:36:54 +0000 Subject: [PATCH 3/4] Add registry helper function to reduce code duplication Co-authored-by: offhub <6871698+offhub@users.noreply.github.com> --- SandboxiePlus/QSbieAPI/SbieUtils.cpp | 55 ++++++++++------------------ SandboxiePlus/QSbieAPI/SbieUtils.h | 1 + 2 files changed, 21 insertions(+), 35 deletions(-) diff --git a/SandboxiePlus/QSbieAPI/SbieUtils.cpp b/SandboxiePlus/QSbieAPI/SbieUtils.cpp index cc285ba7e14..fe45165c5a3 100644 --- a/SandboxiePlus/QSbieAPI/SbieUtils.cpp +++ b/SandboxiePlus/QSbieAPI/SbieUtils.cpp @@ -380,23 +380,27 @@ int CSbieUtils::ExecCommandEx(const QString& Command, QString* pOutput, quint32 ////////////////////////////////////////////////////////////////////////////// // Shell integration -QString CSbieUtils::GetContextMenuStartCmd() +QString CSbieUtils::ReadRegistryValue(HKEY rootKey, const QString& keyPath, const QString& valueName) { - const wchar_t* key = L"Software\\Classes\\*\\shell\\sandbox\\command"; HKEY hkey; - LONG rc = RegOpenKeyExW(HKEY_CURRENT_USER, key, 0, KEY_READ, &hkey); + LONG rc = RegOpenKeyExW(rootKey, keyPath.toStdWString().c_str(), 0, KEY_READ, &hkey); if (rc != 0) return QString(); ULONG type; - WCHAR path[512]; - ULONG path_len = sizeof(path) - sizeof(WCHAR) * 4; - rc = RegQueryValueExW(hkey, NULL, NULL, &type, (BYTE *)path, &path_len); + WCHAR buffer[512]; + ULONG buffer_len = sizeof(buffer) - sizeof(WCHAR) * 4; + rc = RegQueryValueExW(hkey, valueName.isEmpty() ? NULL : valueName.toStdWString().c_str(), NULL, &type, (BYTE *)buffer, &buffer_len); RegCloseKey(hkey); if (rc != 0) return QString(); - return QString::fromWCharArray(path); + return QString::fromWCharArray(buffer); +} + +QString CSbieUtils::GetContextMenuStartCmd() +{ + return ReadRegistryValue(HKEY_CURRENT_USER, "Software\\Classes\\*\\shell\\sandbox\\command"); } void CSbieUtils::AddContextMenuHelper(const QString& StartPath, const QString& RunStr, const QString& IconPath, const QString& shellKey, const QString& command, bool forFiles, bool forFolders, const QString& iconSuffix) @@ -413,30 +417,17 @@ void CSbieUtils::AddContextMenuHelper(const QString& StartPath, const QString& R // Special handling for the original sandbox context menu if (shellKey == "sandbox") { - std::wstring explorer_path(512, L'\0'); - - HKEY hkeyWinlogon; - LONG rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"software\\microsoft\\windows nt\\currentversion\\winlogon", 0, KEY_READ, &hkeyWinlogon); - if (rc == 0) - { - ULONG path_len = explorer_path.size() * sizeof(WCHAR); - ULONG type; - rc = RegQueryValueExW(hkeyWinlogon, L"Shell", NULL, &type, (BYTE *)explorer_path.c_str(), &path_len); - if (rc == 0 && (type == REG_SZ || type == REG_EXPAND_SZ)) - explorer_path.resize(path_len / sizeof(WCHAR)); - RegCloseKey(hkeyWinlogon); - } - + QString explorerPath = ReadRegistryValue(HKEY_LOCAL_MACHINE, "software\\microsoft\\windows nt\\currentversion\\winlogon", "Shell"); + // get default explorer path - if (*explorer_path.c_str() == L'\0' || _wcsicmp(explorer_path.c_str(), L"explorer.exe") == 0) + if (explorerPath.isEmpty() || explorerPath.compare("explorer.exe", Qt::CaseInsensitive) == 0) { - GetWindowsDirectoryW((wchar_t*)explorer_path.c_str(), MAX_PATH); - ULONG path_len = wcslen(explorer_path.c_str()); - explorer_path.resize(path_len); - explorer_path.append(L"\\explorer.exe"); + WCHAR winDir[MAX_PATH]; + GetWindowsDirectoryW(winDir, MAX_PATH); + explorerPath = QString::fromWCharArray(winDir) + "\\explorer.exe"; } - folder_command += explorer_path + L" \"%1\""; + folder_command += explorerPath.toStdWString() + L" \"%1\""; } else { folder_command += L"\"%1\" %*"; } @@ -492,14 +483,8 @@ void CSbieUtils::RemoveContextMenu() bool CSbieUtils::HasContextMenuHelper(const QString& shellKey) { - std::wstring key = L"Software\\Classes\\*\\shell\\" + shellKey.toStdWString() + L"\\command"; - HKEY hkey; - LONG rc = RegOpenKeyExW(HKEY_CURRENT_USER, key.c_str(), 0, KEY_READ, &hkey); - if (rc != 0) - return false; - - RegCloseKey(hkey); - return true; + QString keyPath = QString("Software\\Classes\\*\\shell\\%1\\command").arg(shellKey); + return !ReadRegistryValue(HKEY_CURRENT_USER, keyPath).isEmpty(); } bool CSbieUtils::HasContextMenu2() diff --git a/SandboxiePlus/QSbieAPI/SbieUtils.h b/SandboxiePlus/QSbieAPI/SbieUtils.h index 50400c0c76d..ca5de0a3b3c 100644 --- a/SandboxiePlus/QSbieAPI/SbieUtils.h +++ b/SandboxiePlus/QSbieAPI/SbieUtils.h @@ -66,6 +66,7 @@ class QSBIEAPI_EXPORT CSbieUtils static void AddContextMenuHelper(const QString& StartPath, const QString& RunStr, const QString& IconPath, const QString& shellKey, const QString& command, bool forFiles, bool forFolders, const QString& iconSuffix = QString()); static bool HasContextMenuHelper(const QString& shellKey); static void RemoveContextMenuHelper(const QString& shellKey, bool forFiles, bool forFolders); + static QString ReadRegistryValue(HKEY rootKey, const QString& keyPath, const QString& valueName = QString()); }; From aa8e33b733d3c27f67a55c074179e47aa826f4f9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 17 Jul 2025 17:40:46 +0000 Subject: [PATCH 4/4] Add helper function for application directory path to reduce duplication Co-authored-by: offhub <6871698+offhub@users.noreply.github.com> --- SandboxiePlus/QSbieAPI/SbieUtils.cpp | 7 ++++++- SandboxiePlus/QSbieAPI/SbieUtils.h | 1 + SandboxiePlus/SandMan/Engine/SbieObject.cpp | 4 ++-- SandboxiePlus/SandMan/SandMan.cpp | 2 +- SandboxiePlus/SandMan/Windows/SettingsWindow.cpp | 16 ++++++++-------- 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/SandboxiePlus/QSbieAPI/SbieUtils.cpp b/SandboxiePlus/QSbieAPI/SbieUtils.cpp index fe45165c5a3..3db62dcd28c 100644 --- a/SandboxiePlus/QSbieAPI/SbieUtils.cpp +++ b/SandboxiePlus/QSbieAPI/SbieUtils.cpp @@ -163,7 +163,7 @@ SB_RESULT(void*) CSbieUtils::Install(EComponent Component) void CSbieUtils::Install(EComponent Component, QStringList& Ops) { - QString HomePath = QCoreApplication::applicationDirPath().replace("/", "\\"); // "C:\\Program Files\\Sandboxie " + QString HomePath = GetApplicationDirPath(); // "C:\\Program Files\\Sandboxie" if ((Component & eDriver) != 0 && GetServiceStatus(SBIEDRV) == 0) Ops.append(QString::fromWCharArray(L"kmdutil.exe|install|" SBIEDRV L"|") + HomePath + "\\" + QString::fromWCharArray(SBIEDRV_SYS) + "|type=kernel|start=demand|altitude=86900"); if ((Component & eService) != 0 && GetServiceStatus(SBIESVC) == 0) { @@ -380,6 +380,11 @@ int CSbieUtils::ExecCommandEx(const QString& Command, QString* pOutput, quint32 ////////////////////////////////////////////////////////////////////////////// // Shell integration +QString CSbieUtils::GetApplicationDirPath() +{ + return QCoreApplication::applicationDirPath().replace("/", "\\"); +} + QString CSbieUtils::ReadRegistryValue(HKEY rootKey, const QString& keyPath, const QString& valueName) { HKEY hkey; diff --git a/SandboxiePlus/QSbieAPI/SbieUtils.h b/SandboxiePlus/QSbieAPI/SbieUtils.h index ca5de0a3b3c..161410dc1ee 100644 --- a/SandboxiePlus/QSbieAPI/SbieUtils.h +++ b/SandboxiePlus/QSbieAPI/SbieUtils.h @@ -67,6 +67,7 @@ class QSBIEAPI_EXPORT CSbieUtils static bool HasContextMenuHelper(const QString& shellKey); static void RemoveContextMenuHelper(const QString& shellKey, bool forFiles, bool forFolders); static QString ReadRegistryValue(HKEY rootKey, const QString& keyPath, const QString& valueName = QString()); + static QString GetApplicationDirPath(); }; diff --git a/SandboxiePlus/SandMan/Engine/SbieObject.cpp b/SandboxiePlus/SandMan/Engine/SbieObject.cpp index b6dc5376f48..01017324987 100644 --- a/SandboxiePlus/SandMan/Engine/SbieObject.cpp +++ b/SandboxiePlus/SandMan/Engine/SbieObject.cpp @@ -200,9 +200,9 @@ void CSbieObject::ShellInstall(const QVariantMap& Options) { CSettingsWindow::AddContextMenu(Options["legacy"].toBool()); if (Options["runUnBoxed"].toBool()) { - CSbieUtils::AddContextMenu2(QApplication::applicationDirPath().replace("/", "\\") + "\\SandMan.exe", + CSbieUtils::AddContextMenu2(CSbieUtils::GetApplicationDirPath() + "\\SandMan.exe", tr("Run &Un-Sandboxed"), - QApplication::applicationDirPath().replace("/", "\\") + "\\Start.exe"); + CSbieUtils::GetApplicationDirPath() + "\\Start.exe"); } } diff --git a/SandboxiePlus/SandMan/SandMan.cpp b/SandboxiePlus/SandMan/SandMan.cpp index c048daa8f3e..b0e280918e2 100644 --- a/SandboxiePlus/SandMan/SandMan.cpp +++ b/SandboxiePlus/SandMan/SandMan.cpp @@ -2484,7 +2484,7 @@ void CSandMan::OnStatusChanged() theAPI->GetGlobalSettings()->SetText("FileRootPath", BoxPath + "\\%SANDBOX%"); } - if (SbiePath.compare(QApplication::applicationDirPath().replace("/", "\\"), Qt::CaseInsensitive) == 0) + if (SbiePath.compare(CSbieUtils::GetApplicationDirPath(), Qt::CaseInsensitive) == 0) { QString AgentCmd = theAPI->GetUserSettings()->GetText("SbieCtrl_AutoStartAgent"); if (AgentCmd.isEmpty() || AgentCmd == "SandMan.exe") diff --git a/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp b/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp index ed4980d4357..75e767b9c1d 100644 --- a/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp +++ b/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp @@ -939,9 +939,9 @@ void CSettingsWindow::AddContextMenu(bool bAlwaysClassic) return; } - CSbieUtils::AddContextMenu(QApplication::applicationDirPath().replace("/", "\\") + "\\SandMan.exe", + CSbieUtils::AddContextMenu(CSbieUtils::GetApplicationDirPath() + "\\SandMan.exe", CSettingsWindow::tr("Run &Sandboxed"), //CSettingsWindow::tr("Explore &Sandboxed"), - QApplication::applicationDirPath().replace("/", "\\") + "\\Start.exe"); + CSbieUtils::GetApplicationDirPath() + "\\Start.exe"); } void CSettingsWindow::RemoveContextMenu() @@ -1544,26 +1544,26 @@ void CSettingsWindow::SaveSettings() if (ui.chkShellMenu2->isChecked() != CSbieUtils::HasContextMenu2()) { if (ui.chkShellMenu2->isChecked()) { - CSbieUtils::AddContextMenu2(QApplication::applicationDirPath().replace("/", "\\") + "\\SandMan.exe", + CSbieUtils::AddContextMenu2(CSbieUtils::GetApplicationDirPath() + "\\SandMan.exe", tr("Run &Un-Sandboxed"), - QApplication::applicationDirPath().replace("/", "\\") + "\\Start.exe"); + CSbieUtils::GetApplicationDirPath() + "\\Start.exe"); } else CSbieUtils::RemoveContextMenu2(); } if (ui.chkShellMenu3->isChecked() != CSbieUtils::HasContextMenu3()) { if (ui.chkShellMenu3->isChecked()) { - CSbieUtils::AddContextMenu3(QApplication::applicationDirPath().replace("/", "\\") + "\\SandMan.exe", + CSbieUtils::AddContextMenu3(CSbieUtils::GetApplicationDirPath() + "\\SandMan.exe", tr("Set Force in Sandbox"), - QApplication::applicationDirPath().replace("/", "\\") + "\\Start.exe"); + CSbieUtils::GetApplicationDirPath() + "\\Start.exe"); } else CSbieUtils::RemoveContextMenu3(); } if (ui.chkShellMenu4->isChecked() != CSbieUtils::HasContextMenu4()) { if (ui.chkShellMenu4->isChecked()) { - CSbieUtils::AddContextMenu4(QApplication::applicationDirPath().replace("/", "\\") + "\\SandMan.exe", + CSbieUtils::AddContextMenu4(CSbieUtils::GetApplicationDirPath() + "\\SandMan.exe", tr("Set Open Path in Sandbox"), - QApplication::applicationDirPath().replace("/", "\\") + "\\Start.exe"); + CSbieUtils::GetApplicationDirPath() + "\\Start.exe"); } else CSbieUtils::RemoveContextMenu4();