9
检测是否以具有或没有提升特权的管理员身份运行?
我有一个应用程序,需要检测它是否正在以提升的特权运行。我目前有这样的代码设置: static bool IsAdministrator() { WindowsIdentity identity = WindowsIdentity.GetCurrent(); WindowsPrincipal principal = new WindowsPrincipal(identity); return principal.IsInRole (WindowsBuiltInRole.Administrator); } 这可以检测用户是否是管理员,但是如果以没有提升权限的管理员身份运行则无法使用。(例如,在vshost.exe中)。 如何确定高程是否已经生效?