mirror of
https://github.com/MatsuriDayo/nekoray.git
synced 2025-12-17 20:44:38 +03:00
25 lines
621 B
C++
25 lines
621 B
C++
|
|
#include "guihelper.h"
|
|
|
|
#include <QWidget>
|
|
|
|
#include <windows.h>
|
|
#include <shlobj.h>
|
|
|
|
void Windows_QWidget_SetForegroundWindow(QWidget *w) {
|
|
HWND hForgroundWnd = GetForegroundWindow();
|
|
DWORD dwForeID = ::GetWindowThreadProcessId(hForgroundWnd, NULL);
|
|
DWORD dwCurID = ::GetCurrentThreadId();
|
|
::AttachThreadInput(dwCurID, dwForeID, TRUE);
|
|
::SetForegroundWindow((HWND) w->winId());
|
|
::AttachThreadInput(dwCurID, dwForeID, FALSE);
|
|
}
|
|
|
|
int isThisAdmin = -1; // cached
|
|
|
|
bool Windows_IsInAdmin() {
|
|
if (isThisAdmin >= 0) return isThisAdmin;
|
|
isThisAdmin = IsUserAnAdmin();
|
|
return isThisAdmin;
|
|
}
|