Skip to content

Commit

Permalink
Merge pull request #2 from love-code-yeyixiao/SuspendHotKey
Browse files Browse the repository at this point in the history
Added the“Restart as administrator” feature
  • Loading branch information
love-code-yeyixiao authored Feb 27, 2024
2 parents 37cacdd + 063ba77 commit c91f603
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions SandboxiePlus/SandMan/SandMan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,14 +507,15 @@ void CSandMan::CreateMenus(bool bAdvanced)
m_pNewBox = m_pMenuFile->addAction(CSandMan::GetIcon("NewBox"), tr("Create New Box"), this, SLOT(OnSandBoxAction()));
m_pNewGroup = m_pMenuFile->addAction(CSandMan::GetIcon("Group"), tr("Create Box Group"), this, SLOT(OnSandBoxAction()));
m_pImportBox = m_pMenuFile->addAction(CSandMan::GetIcon("UnPackBox"), tr("Import Box"), this, SLOT(OnSandBoxAction()));

m_pImportBox->setEnabled(CArchive::IsInit());
m_pMenuFile->addSeparator();
m_pRunBoxed = m_pMenuFile->addAction(CSandMan::GetIcon("Run"), tr("Run Sandboxed"), this, SLOT(OnSandBoxAction()));
m_pEmptyAll = m_pMenuFile->addAction(CSandMan::GetIcon("EmptyAll"), tr("Terminate All Processes"), this, SLOT(OnEmptyAll()));
m_pLockAll = m_pMenuFile->addAction(CSandMan::GetIcon("LockClosed"), tr("Lock All Encrypted Boxes"), this, SLOT(OnLockAll()));
m_pMenuFile->addSeparator();
m_pWndFinder = m_pMenuFile->addAction(CSandMan::GetIcon("finder"), tr("Is Window Sandboxed?"), this, SLOT(OnWndFinder()));

if(bAdvanced || theGUI->IsFullyPortable())
CreateMaintenanceMenu();
else {
Expand All @@ -537,6 +538,7 @@ void CSandMan::CreateMenus(bool bAdvanced)
}

m_pMenuFile->addSeparator();
m_pRestart = m_pMenuFile->addAction(CSandMan::GetIcon("Exit"), tr("Restart As Admin"), this, SLOT(OnRestartAsAdmin()));
m_pExit = m_pMenuFile->addAction(CSandMan::GetIcon("Exit"), tr("Exit"), this, SLOT(OnExit()));


Expand Down Expand Up @@ -862,6 +864,7 @@ QList<ToolBarAction> CSandMan::GetAvailableToolBarActions()
ToolBarAction{ "CheckForUpdates", m_pUpdate },
ToolBarAction{ "About", m_pAbout },
ToolBarAction{ "", nullptr }, // separator
ToolBarAction{ "RestartAsAdmin", m_pRestart },
ToolBarAction{ "Exit", m_pExit },
ToolBarAction{ "", nullptr }, // separator
ToolBarAction{ "Contribute", m_pContribution }
Expand Down Expand Up @@ -1296,7 +1299,20 @@ void CSandMan::CheckForUpdates(bool bManual)
}

#include "SandManTray.cpp"

void CSandMan::OnRestartAsAdmin() {
theAPI->Disconnect();
WCHAR buf[255] = { 0 };
GetModuleFileNameW(NULL, buf, 255);
SHELLEXECUTEINFO se;
memset(&se, 0, sizeof(SHELLEXECUTEINFO));
se.cbSize = sizeof(SHELLEXECUTEINFO);
se.lpVerb = L"runas";
se.lpFile = buf;
se.nShow = SW_HIDE;
se.fMask = 0;
ShellExecuteEx(&se);
OnExit();
}
void CSandMan::OnExit()
{
m_bExit = true;
Expand Down

0 comments on commit c91f603

Please sign in to comment.