wip: tun privilege

This commit is contained in:
arm64v8a
2023-03-20 21:48:21 +09:00
parent 20c8fe5f0a
commit 69771e2080
10 changed files with 63 additions and 8 deletions

View File

@@ -4,8 +4,9 @@
#include <QWidget>
#include <windows.h>
#include <shlobj.h>
void Windows_QWidget_SetForegroundWindow(QWidget* w) {
void Windows_QWidget_SetForegroundWindow(QWidget *w) {
HWND hForgroundWnd = GetForegroundWindow();
DWORD dwForeID = ::GetWindowThreadProcessId(hForgroundWnd, NULL);
DWORD dwCurID = ::GetCurrentThreadId();
@@ -13,3 +14,11 @@ void Windows_QWidget_SetForegroundWindow(QWidget* w) {
::SetForegroundWindow((HWND) w->winId());
::AttachThreadInput(dwCurID, dwForeID, FALSE);
}
int isThisAdmin = -1; // cached
bool Windows_IsInAdmin() {
if (isThisAdmin >= 0) return isThisAdmin;
isThisAdmin = IsUserAnAdmin();
return isThisAdmin;
}