检测系统启动模式

实现效果:

  

知识运用:

  SystemInformation类的BootMode属性

  public static BootMode BootMode { get; }  //获取一个BootMode值以指示系统的启动模式

  

实现代码:

        private void button1_Click(object sender, EventArgs e)
        {
            string mode = SystemInformation.BootMode.ToString();
            string str = "当前系统启动模式为:";
            switch (mode)
            {
                case "FailSafe":
                    MessageBox.Show(str + "不带网络支持的安全模式");
                    break;
                case "FailSafeWithNetwork":
                    MessageBox.Show(str + "具有网络支持的安全模式");
                    break;
                case "Normal":
                    MessageBox.Show(str + "标准模式");
                    break;
            }
        }

  

猜你喜欢

转载自www.cnblogs.com/feiyucha/p/10316077.html