In .NET/C# test if process has administrative privileges

前端 未结 10 1999
天涯浪人
天涯浪人 2020-11-27 03:35

Is there a canonical way to test to see if the process has administrative privileges on a machine?

I\'m going to be starting a long running process, and much later

10条回答
  •  醉话见心
    2020-11-27 04:32

    What about:

    using System.Runtime.InteropServices;
    
    internal static class Useful {
        [DllImport("shell32.dll", EntryPoint = "IsUserAnAdmin")]
        public static extern bool IsUserAnAdministrator();
    }
    

提交回复
热议问题