如何确定当前程序是否运行在Administrator模式下

        WindowsIdentity  identity  = WindowsIdentity.GetCurrent();
        WindowsPrincipal principal = new WindowsPrincipal(identity);
        if (!principal.IsInRole(WindowsBuiltInRole.Administrator))
        {
            MessageBox.Show("You must run this application as administrator. Terminating.");
            Application.Exit();
        }




posted @ 2012-01-09 13:04  队长  阅读(252)  评论(0编辑  收藏  举报