如何确定当前程序是否运行在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();
        }




你可能感兴趣的:(ini)