将计算机设置为休眠状态

Posted on 2019-01-22 10:21  努力成长静待花开  阅读(427)  评论(0编辑  收藏  举报

实现效果:

  

知识运用:

  Application类的SetSuspendState方法     //挂起系统或使系统休眠

  public static bool SetSuspendState (PowerState state ,bool force , bool  disableWakeEvent)

  

实现代码:

        private void button1_Click(object sender, EventArgs e)
        {
            Application.SetSuspendState(PowerState.Hibernate,true,false);
        }