39 lines
665 B
C#
39 lines
665 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
using System.Security.Principal;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace MAX.Framework.Helpers;
|
|
|
|
public class SystemHelper
|
|
{
|
|
public static bool IsAdministratorSafe
|
|
{
|
|
get
|
|
{
|
|
try
|
|
{
|
|
return IsAdministrator;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Debug.WriteLine(ex);
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public static bool IsAdministrator
|
|
{
|
|
get
|
|
{
|
|
WindowsIdentity current = WindowsIdentity.GetCurrent();
|
|
WindowsPrincipal windowsPrincipal = new(current);
|
|
return windowsPrincipal.IsInRole(WindowsBuiltInRole.Administrator);
|
|
}
|
|
}
|
|
} |