Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invoke application from Application Toolbar as Administrator, if Control key is pressed during Drag & Drop (or click). #204

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Explorer++/Explorer++/ApplicationToolbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,11 @@ void ApplicationToolbar::OpenItem(int iItem, std::wstring *parameters)
combinedParameters.append(_T(" "));
combinedParameters.append(*parameters);
}

// Run it as Admin if Control key is pressed.
bool RunAsAdmin = (GetKeyState(VK_CONTROL) & (1 << 7) ? true : false);

m_pexpp->OpenFileItem(pidl.get(), combinedParameters.c_str());
m_pexpp->OpenFileItem(pidl.get(), combinedParameters.c_str(), RunAsAdmin);
}
}
}
Expand Down Expand Up @@ -671,4 +674,4 @@ bool ApplicationToolbarPersistentSettings::AddButton(const std::wstring &name, c
}

return true;
}
}
4 changes: 2 additions & 2 deletions Explorer++/Explorer++/CoreInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ __interface IExplorerplusplus

StatusBar *GetStatusBar();

void OpenFileItem(PCIDLIST_ABSOLUTE pidlItem, const TCHAR *szParameters);
void OpenFileItem(PCIDLIST_ABSOLUTE pidlItem, const TCHAR *szParameters, bool RunAsAdmin);

HMENU BuildViewsMenu();

Expand All @@ -80,4 +80,4 @@ __interface IExplorerplusplus
boost::signals2::connection AddTabsInitializedObserver(const TabsInitializedSignal::slot_type &observer);
boost::signals2::connection AddMainMenuPreShowObserver(const MainMenuPreShowSignal::slot_type &observer);
boost::signals2::connection AddToolbarContextMenuObserver(const ToolbarContextMenuSignal::slot_type &observer);
};
};
4 changes: 2 additions & 2 deletions Explorer++/Explorer++/Explorer++.h
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ class Explorerplusplus :
void OpenItem(const TCHAR *szItem, BOOL bOpenInNewTab, BOOL bOpenInNewWindow) override;
void OpenItem(PCIDLIST_ABSOLUTE pidlItem, BOOL bOpenInNewTab, BOOL bOpenInNewWindow) override;
void OpenFolderItem(PCIDLIST_ABSOLUTE pidlItem, BOOL bOpenInNewTab, BOOL bOpenInNewWindow);
void OpenFileItem(PCIDLIST_ABSOLUTE pidlItem, const TCHAR *szParameters) override;
void OpenFileItem(PCIDLIST_ABSOLUTE pidlItem, const TCHAR *szParameters, bool RunAsAdmin) override;
HRESULT OnListViewCopy(BOOL bCopy);

/* File context menu. */
Expand Down Expand Up @@ -639,4 +639,4 @@ class Explorerplusplus :
HTREEITEM m_hTVMButtonItem;

BOOL m_blockNextListViewSelection;
};
};
14 changes: 8 additions & 6 deletions Explorer++/Explorer++/MsgHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ void Explorerplusplus::OpenItem(PCIDLIST_ABSOLUTE pidlItem, BOOL bOpenInNewTab,
}
else
{
OpenFileItem(pidlItem,EMPTY_STRING);
OpenFileItem(pidlItem,EMPTY_STRING,false);
}
}
else if(((uAttributes & SFGAO_FOLDER) && !bControlPanelParent))
Expand Down Expand Up @@ -255,7 +255,7 @@ void Explorerplusplus::OpenItem(PCIDLIST_ABSOLUTE pidlItem, BOOL bOpenInNewTab,
Also, even if the shortcut points to a dead
folder, it should still attempted to be
opened. */
OpenFileItem(pidlItem,EMPTY_STRING);
OpenFileItem(pidlItem,EMPTY_STRING,false);
}
}
else if(bControlPanelParent && (uAttributes & SFGAO_FOLDER))
Expand All @@ -280,7 +280,7 @@ void Explorerplusplus::OpenItem(PCIDLIST_ABSOLUTE pidlItem, BOOL bOpenInNewTab,
else
{
/* File item. */
OpenFileItem(pidlItem,EMPTY_STRING);
OpenFileItem(pidlItem,EMPTY_STRING,false);
}
}
}
Expand All @@ -295,15 +295,17 @@ void Explorerplusplus::OpenFolderItem(PCIDLIST_ABSOLUTE pidlItem, BOOL bOpenInNe
m_navigation->BrowseFolderInCurrentTab(pidlItem);
}

void Explorerplusplus::OpenFileItem(PCIDLIST_ABSOLUTE pidlItem,const TCHAR *szParameters)
void Explorerplusplus::OpenFileItem(PCIDLIST_ABSOLUTE pidlItem, const TCHAR *szParameters, bool RunAsAdmin)
{
unique_pidl_absolute pidlParent(ILCloneFull(pidlItem));
ILRemoveLastID(pidlParent.get());

TCHAR szItemDirectory[MAX_PATH];
GetDisplayName(pidlParent.get(),szItemDirectory,SIZEOF_ARRAY(szItemDirectory),SHGDN_FORPARSING);

const TCHAR *szVerb = (RunAsAdmin ? _T("RunAs") : EMPTY_STRING);

ExecuteFileAction(m_hContainer,EMPTY_STRING,szParameters,szItemDirectory,pidlItem);
ExecuteFileAction(m_hContainer,szVerb,szParameters,szItemDirectory,pidlItem);
}

BOOL Explorerplusplus::OnSize(int MainWindowWidth,int MainWindowHeight)
Expand Down Expand Up @@ -1506,4 +1508,4 @@ void Explorerplusplus::OnShowHiddenFiles()
Tab &tab = m_tabContainer->GetSelectedTab();
tab.GetShellBrowser()->SetShowHidden(!tab.GetShellBrowser()->GetShowHidden());
tab.GetShellBrowser()->GetNavigationController()->Refresh();
}
}