mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
runner: show message box when restarting with different elevation fails (#1061)
Also make the message box appear on top of the settings window.
This commit is contained in:
committed by
GitHub
parent
a2a683d31e
commit
dad732b7e6
@@ -310,6 +310,33 @@ bool run_non_elevated(const std::wstring& file, const std::wstring& params) {
|
||||
return succedded;
|
||||
}
|
||||
|
||||
bool run_same_elevation(const std::wstring& file, const std::wstring& params) {
|
||||
auto executable_args = file;
|
||||
if (!params.empty()) {
|
||||
executable_args += L" " + params;
|
||||
}
|
||||
STARTUPINFO si = { 0 };
|
||||
PROCESS_INFORMATION pi = { 0 };
|
||||
auto succedded = CreateProcessW(file.c_str(),
|
||||
const_cast<LPWSTR>(executable_args.c_str()),
|
||||
nullptr,
|
||||
nullptr,
|
||||
FALSE,
|
||||
0,
|
||||
nullptr,
|
||||
nullptr,
|
||||
&si,
|
||||
&pi);
|
||||
if (pi.hProcess) {
|
||||
CloseHandle(pi.hProcess);
|
||||
}
|
||||
if (pi.hThread) {
|
||||
CloseHandle(pi.hThread);
|
||||
}
|
||||
return succedded;
|
||||
}
|
||||
|
||||
|
||||
std::wstring get_process_path(HWND window) noexcept {
|
||||
const static std::wstring app_frame_host = L"ApplicationFrameHost.exe";
|
||||
DWORD pid{};
|
||||
|
||||
Reference in New Issue
Block a user