summaryrefslogtreecommitdiff
path: root/Source/Core/Updater/WinUI.cpp
diff options
context:
space:
mode:
authorspycrab <spycrab@users.noreply.github.com>2019-03-03 13:56:54 +0100
committerspycrab <spycrab@users.noreply.github.com>2019-03-03 15:02:44 +0100
commit19bf2c166d9bc1647a3d055dbdeca87e8cdf5a06 (patch)
tree3b44f31970cdbadc9f2820b57984ccd5db48fe40 /Source/Core/Updater/WinUI.cpp
parent2a3c0753303a9f4cd79a92cd94b6a22298b516d6 (diff)
UpdaterCommon: Move most of the programs here
Diffstat (limited to 'Source/Core/Updater/WinUI.cpp')
-rw-r--r--Source/Core/Updater/WinUI.cpp37
1 files changed, 35 insertions, 2 deletions
diff --git a/Source/Core/Updater/WinUI.cpp b/Source/Core/Updater/WinUI.cpp
index 8d73236c29..682ea1e545 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"
@@ -29,7 +31,7 @@ constexpr int PROGRESSBAR_FLAGS = WS_VISIBLE | WS_CHILD | PBS_SMOOTH | PBS_SMOOT
namespace UI
{
-bool Init()
+bool InitWindow()
{
InitCommonControls();
@@ -168,7 +170,7 @@ void MessageLoop()
request_stop.Clear();
running.Set();
- if (!Init())
+ if (!InitWindow())
{
running.Clear();
MessageBox(nullptr, L"Window init failed!", L"", MB_ICONERROR);
@@ -192,6 +194,12 @@ void MessageLoop()
Destroy();
}
+void Init()
+{
+ std::thread thread(MessageLoop);
+ thread.detach();
+}
+
void Stop()
{
if (!running.IsSet())
@@ -203,4 +211,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