mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-01-11 19:44:55 +00:00
feat: Added property to ProgramUtils to determine if the application is running as admin
This commit is contained in:
@@ -32,8 +32,6 @@
|
|||||||
<None Remove="binNetCoreApp\**" />
|
<None Remove="binNetCoreApp\**" />
|
||||||
<None Remove="SIMPLSharpLogs\**" />
|
<None Remove="SIMPLSharpLogs\**" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Remove="ICD.Common.projectinfo" />
|
<None Remove="ICD.Common.projectinfo" />
|
||||||
<None Remove="ICD.Common_SimplSharp.suo" />
|
<None Remove="ICD.Common_SimplSharp.suo" />
|
||||||
@@ -47,6 +45,7 @@
|
|||||||
<PackageReference Include="Pastel" Version="2.1.0" />
|
<PackageReference Include="Pastel" Version="2.1.0" />
|
||||||
<PackageReference Include="System.Net.NetworkInformation" Version="4.3.0" />
|
<PackageReference Include="System.Net.NetworkInformation" Version="4.3.0" />
|
||||||
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
|
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
|
||||||
|
<PackageReference Include="System.Security.Principal.Windows" Version="5.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Update="CultureInfo.sqlite">
|
<None Update="CultureInfo.sqlite">
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using ICD.Common.Utils.IO;
|
using ICD.Common.Utils.IO;
|
||||||
using System;
|
using System;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Security.Principal;
|
||||||
using ICD.Common.Properties;
|
using ICD.Common.Properties;
|
||||||
|
|
||||||
namespace ICD.Common.Utils
|
namespace ICD.Common.Utils
|
||||||
@@ -64,6 +65,19 @@ namespace ICD.Common.Utils
|
|||||||
{
|
{
|
||||||
get { return IcdFile.GetCreationTime(PathUtils.Join(PathUtils.ProgramPath, ProgramFile)); }
|
get { return IcdFile.GetCreationTime(PathUtils.Join(PathUtils.ProgramPath, ProgramFile)); }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if the current executing user is an admin.
|
||||||
|
/// </summary>
|
||||||
|
[PublicAPI]
|
||||||
|
public static bool IsElevated
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
WindowsIdentity current = WindowsIdentity.GetCurrent();
|
||||||
|
return new WindowsPrincipal(current).IsInRole(WindowsBuiltInRole.Administrator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user