OpenFile Shell
This commit is contained in:
parent
17965f4f89
commit
c1205fd043
|
@ -523,6 +523,43 @@ void CSbieUtils::RemoveContextMenu3()
|
|||
RegDeleteTreeW(HKEY_CURRENT_USER, L"software\\classes\\folder\\shell\\addforce");
|
||||
}
|
||||
|
||||
|
||||
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 = RegOpenKeyEx(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;
|
||||
}
|
||||
|
||||
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\" %*");
|
||||
}
|
||||
|
||||
void CSbieUtils::RemoveContextMenu4()
|
||||
{
|
||||
RegDeleteTreeW(HKEY_CURRENT_USER, L"software\\classes\\*\\shell\\addopen");
|
||||
RegDeleteTreeW(HKEY_CURRENT_USER, L"software\\classes\\folder\\shell\\addopen");
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Shortcuts
|
||||
|
||||
|
|
|
@ -40,6 +40,10 @@ public:
|
|||
static void AddContextMenu3(const QString& StartPath, const QString& RunStr, const QString& IconPath = QString());
|
||||
static void RemoveContextMenu3();
|
||||
|
||||
static bool HasContextMenu4();
|
||||
static void AddContextMenu4(const QString& StartPath, const QString& RunStr, const QString& IconPath = QString());
|
||||
static void RemoveContextMenu4();
|
||||
|
||||
static bool CreateShortcut(const QString& StartExe, QString LinkPath, const QString &LinkName, const QString &boxname, const QString &arguments, const QString &iconPath = QString(), int iconIndex = 0, const QString &workdir = QString(), bool bRunElevated = false);
|
||||
static bool GetStartMenuShortcut(class CSbieAPI* pApi, QString &BoxName, QString &LinkPath, QString &IconPath, quint32& IconIndex, QString &WorkDir);
|
||||
|
||||
|
|
|
@ -1636,7 +1636,7 @@ void CSandMan::OnMessage(const QString& MsgData)
|
|||
setWindowState(Qt::WindowActive);
|
||||
SetForegroundWindow(MainWndHandle);
|
||||
}
|
||||
else if (Message.left(4) == "Add:")
|
||||
else if (Message.left(9) == "AddForce:")
|
||||
{
|
||||
|
||||
|
||||
|
@ -1660,6 +1660,24 @@ void CSandMan::OnMessage(const QString& MsgData)
|
|||
QMessageBox::warning(g_GUIParent, tr("Sandboxie-Plus Warning"), tr("Users canceled this operation."), QMessageBox::Yes, 0);
|
||||
}
|
||||
}
|
||||
else if (Message.left(8) == "AddOpen:")
|
||||
{
|
||||
|
||||
|
||||
QString respone = QInputDialog::getText(g_GUIParent, tr("Which box you want to add in?"), tr("Type the box name which you are going to set:"));
|
||||
if (!respone.isEmpty())
|
||||
{
|
||||
if (theAPI->GetBoxByName(respone) != NULL) {
|
||||
theAPI->GetBoxByName(respone)->AppendText("OpenFilePath", Message.mid(4).replace("\"", ""));
|
||||
}
|
||||
else {
|
||||
QMessageBox::warning(g_GUIParent, tr("Sandboxie-Plus Warning"), tr("You typed a wrong box name!Nothing was changed."), QMessageBox::Ok, 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
QMessageBox::warning(g_GUIParent, tr("Sandboxie-Plus Warning"), tr("Users canceled this operation."), QMessageBox::Yes, 0);
|
||||
}
|
||||
}
|
||||
else if (Message.left(4) == "Run:")
|
||||
{
|
||||
QString BoxName;
|
||||
|
|
|
@ -112,14 +112,20 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
int DfpPos = Args.indexOf("/disable_force", Qt::CaseInsensitive);
|
||||
int AfpPos = Args.indexOf("/add_force", Qt::CaseInsensitive);
|
||||
int AOPos = Args.indexOf("/add_open", Qt::CaseInsensitive);
|
||||
|
||||
//Add_Force has the highest priority.
|
||||
if (AfpPos != -1) {
|
||||
DfpPos = -1;
|
||||
BoxPos = -1;
|
||||
}else
|
||||
}
|
||||
else if (AOPos != -1)
|
||||
{
|
||||
DfpPos = -1;
|
||||
BoxPos = -1;
|
||||
}
|
||||
// the first argument wins
|
||||
if (BoxPos != -1 && DfpPos != -1) {
|
||||
else if (BoxPos != -1 && DfpPos != -1) {
|
||||
if (BoxPos < DfpPos) DfpPos = -1;
|
||||
else BoxPos = -1;
|
||||
}
|
||||
|
@ -169,9 +175,16 @@ int main(int argc, char *argv[])
|
|||
LPWSTR cmdLine0 = wcsstr(GetCommandLineW(), L"/add_force");
|
||||
if (!cmdLine0) return -1;
|
||||
LPWSTR cmdLine = cmdLine0 + 10;
|
||||
g_PendingMessage = "Add:" + QString::fromWCharArray(cmdLine + 1);
|
||||
g_PendingMessage = "AddForce:" + QString::fromWCharArray(cmdLine + 1);
|
||||
|
||||
}
|
||||
|
||||
if (AOPos != -1) {
|
||||
LPWSTR cmdLine0 = wcsstr(GetCommandLineW(), L"/add_open");
|
||||
if (!cmdLine0) return -1;
|
||||
LPWSTR cmdLine = cmdLine0 + 10;
|
||||
g_PendingMessage = "AddOpen:" + QString::fromWCharArray(cmdLine + 1);
|
||||
}
|
||||
|
||||
if (IsBoxed) {
|
||||
QMessageBox::critical(NULL, "Sandboxie-Plus", CSandMan::tr("Sandboxie Manager can not be run sandboxed!"));
|
||||
|
|
Loading…
Reference in New Issue