From e9b22da266b74d722c9e871e078b8929418971fe Mon Sep 17 00:00:00 2001 From: uye <99072975+ABA2396@users.noreply.github.com> Date: Sun, 27 Aug 2023 12:33:21 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E5=90=AF=E5=8A=A8=E6=97=B6=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=E6=98=AF=E5=90=A6=E4=B8=BA=E7=AE=A1=E7=90=86=E5=91=98?= =?UTF-8?q?=E5=90=AF=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MaaWpfGui/Main/Bootstrapper.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/MaaWpfGui/Main/Bootstrapper.cs b/src/MaaWpfGui/Main/Bootstrapper.cs index 3af91320eda..f24069e0800 100644 --- a/src/MaaWpfGui/Main/Bootstrapper.cs +++ b/src/MaaWpfGui/Main/Bootstrapper.cs @@ -15,6 +15,7 @@ using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; +using System.Security.Principal; using System.Windows; using System.Windows.Threading; using GlobalHotKey; @@ -106,6 +107,10 @@ protected override void OnStart() _logger.Information("MaaAssistantArknights GUI started"); _logger.Information("Maa ENV: {MaaEnv}", maaEnv); _logger.Information("User Dir {CurrentDirectory}", Directory.GetCurrentDirectory()); + if (IsUserAdministrator()) + { + _logger.Information("Run as Administrator"); + } _logger.Information("==================================="); try @@ -134,6 +139,15 @@ protected override void OnStart() LocalizationHelper.Load(); } + private static bool IsUserAdministrator() + { + WindowsIdentity identity = WindowsIdentity.GetCurrent(); + WindowsPrincipal principal = new WindowsPrincipal(identity); + SecurityIdentifier adminSid = new SecurityIdentifier(WellKnownSidType.BuiltinAdministratorsSid, null); + + return principal.IsInRole(adminSid); + } + /// protected override void ConfigureIoC(IStyletIoCBuilder builder) {