diff --git a/src/EventLogExpert.UI/Services/AppTitleService.cs b/src/EventLogExpert.UI/Services/AppTitleService.cs index 35ee044e..7a0c8ab8 100644 --- a/src/EventLogExpert.UI/Services/AppTitleService.cs +++ b/src/EventLogExpert.UI/Services/AppTitleService.cs @@ -66,6 +66,11 @@ private void SetTitle() title.Append($" {versionProvider.CurrentVersion}"); } + if (versionProvider.IsAdmin) + { + title.Append(" (Admin)"); + } + titleProvider.SetTitle(title.ToString()); } } diff --git a/src/EventLogExpert.UI/Services/CurrentVersionProvider.cs b/src/EventLogExpert.UI/Services/CurrentVersionProvider.cs index 982f712b..73491311 100644 --- a/src/EventLogExpert.UI/Services/CurrentVersionProvider.cs +++ b/src/EventLogExpert.UI/Services/CurrentVersionProvider.cs @@ -1,6 +1,7 @@ // // Copyright (c) Microsoft Corporation. // // Licensed under the MIT License. +using System.Security.Principal; using Windows.ApplicationModel; namespace EventLogExpert.UI.Services; @@ -9,6 +10,8 @@ public interface ICurrentVersionProvider { Version CurrentVersion { get; } + bool IsAdmin { get; } + bool IsDevBuild { get; } bool IsSupportedOS(Version currentVersion); @@ -24,6 +27,17 @@ public CurrentVersionProvider() public Version CurrentVersion { get; init; } + public bool IsAdmin + { + get + { + var identity = WindowsIdentity.GetCurrent(); + WindowsPrincipal principal = new(identity); + + return principal.IsInRole(WindowsBuiltInRole.Administrator); + } + } + public bool IsDevBuild => CurrentVersion.Major <= 1; public bool IsSupportedOS(Version currentVersion) => currentVersion.CompareTo(new Version(10, 0, 19041, 0)) > 0;