diff options
| author | spycrab <spycrab@users.noreply.github.com> | 2019-03-07 19:09:35 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-03-07 19:09:35 +0100 |
| commit | db2542886a76a3d346fbdb019dec6b0afd53bd84 (patch) | |
| tree | a3dce03c9b5f5c4c98818cfd11b5083dbda67f51 /Source/Core/Updater/WinUI.cpp | |
| parent | 7d17163ce85f518e3951a39ab226a446c32a8e54 (diff) | |
| parent | 19bf2c166d9bc1647a3d055dbdeca87e8cdf5a06 (diff) | |
Merge pull request #7844 from spycrab/updatecommon_electric_boogaloo
UpdaterCommon: Move most of the programs here
Diffstat (limited to 'Source/Core/Updater/WinUI.cpp')
| -rw-r--r-- | Source/Core/Updater/WinUI.cpp | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/Source/Core/Updater/WinUI.cpp b/Source/Core/Updater/WinUI.cpp index b66a8fc92c..7f9a951bef 100644 --- a/Source/Core/Updater/WinUI.cpp +++ b/Source/Core/Updater/WinUI.cpp @@ -5,10 +5,12 @@ #include "UpdaterCommon/UI.h" #include <string> +#include <thread> #include <Windows.h> #include <CommCtrl.h> #include <ShObjIdl.h> +#include <shellapi.h> #include "Common/Flag.h" #include "Common/StringUtil.h" @@ -39,7 +41,7 @@ constexpr int PADDING_HEIGHT = 5; namespace UI { -bool Init() +bool InitWindow() { InitCommonControls(); @@ -200,7 +202,7 @@ void MessageLoop() request_stop.Clear(); running.Set(); - if (!Init()) + if (!InitWindow()) { running.Clear(); MessageBox(nullptr, L"Window init failed!", L"", MB_ICONERROR); @@ -224,6 +226,12 @@ void MessageLoop() Destroy(); } +void Init() +{ + std::thread thread(MessageLoop); + thread.detach(); +} + void Stop() { if (!running.IsSet()) @@ -235,4 +243,29 @@ void Stop() { } } + +void LaunchApplication(std::string path) +{ + // Hack: Launching the updater over the explorer ensures that admin priviliges are dropped. Why? + // Ask Microsoft. + ShellExecuteW(nullptr, nullptr, L"explorer.exe", UTF8ToUTF16(path).c_str(), nullptr, SW_SHOW); +} + +void Sleep(int sleep) +{ + ::Sleep(sleep * 1000); +} + +void WaitForPID(u32 pid) +{ + HANDLE parent_handle = OpenProcess(SYNCHRONIZE, FALSE, static_cast<DWORD>(pid)); + WaitForSingleObject(parent_handle, INFINITE); + CloseHandle(parent_handle); +} + +void SetVisible(bool visible) +{ + ShowWindow(window_handle, visible ? SW_SHOW : SW_HIDE); +} + }; // namespace UI |
