WPF 程序检测 windows 关机

Posted pkyou

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了WPF 程序检测 windows 关机相关的知识,希望对你有一定的参考价值。

1.使用SessionEnding事件

参考MSDN

2.在需要处理 关机事件中可以注册SessionEnding事件

App.Current.SessionEnding += Current_SessionEnding;
        private void Current_SessionEnding(object sender, SessionEndingCancelEventArgs e)
        {
             
             //处理一些事情
            DoExit();
             
        }

 

以上是关于WPF 程序检测 windows 关机的主要内容,如果未能解决你的问题,请参考以下文章