我有一个应用程序需要检测它是否以提升的权限运行.我目前的代码设置如下:
static bool IsAdministrator()
{
WindowsIdentity identity = WindowsIdentity.GetCurrent();
WindowsPrincipal principal = new WindowsPrincipal(identity);
return principal.IsInRole (WindowsBuiltInRole.Administrator);
}
Run Code Online (Sandbox Code Playgroud)
这可以检测用户是否是管理员,但如果以没有提升的管理员身份运行则不起作用.(例如在vshost.exe中).
如何判断高程是否[已经生效或]可能?