Skip to content

Commit

Permalink
Updated title to indicate if app is running elevated
Browse files Browse the repository at this point in the history
  • Loading branch information
jschick04 authored and bill-long committed May 20, 2024
1 parent 4307a7d commit d429ac5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/EventLogExpert.UI/Services/AppTitleService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ private void SetTitle()
title.Append($" {versionProvider.CurrentVersion}");
}

if (versionProvider.IsAdmin)
{
title.Append(" (Admin)");
}

titleProvider.SetTitle(title.ToString());
}
}
14 changes: 14 additions & 0 deletions src/EventLogExpert.UI/Services/CurrentVersionProvider.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// // Copyright (c) Microsoft Corporation.
// // Licensed under the MIT License.

using System.Security.Principal;
using Windows.ApplicationModel;

namespace EventLogExpert.UI.Services;
Expand All @@ -9,6 +10,8 @@ public interface ICurrentVersionProvider
{
Version CurrentVersion { get; }

bool IsAdmin { get; }

bool IsDevBuild { get; }

bool IsSupportedOS(Version currentVersion);
Expand All @@ -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;
Expand Down

0 comments on commit d429ac5

Please sign in to comment.