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

前端 未结 10 2003
天涯浪人
天涯浪人 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:24

    Tried Erwin's code but it didn't compile.

    Got it to work like this:

    [DllImport("shell32.dll")] public static extern bool IsUserAnAdmin();
    

提交回复
热议问题