【问题标题】:Detect restart in Windows 8 - SessionEnding not called在 Windows 8 中检测重新启动 - 未调用 SessionEnding
【发布时间】:2013-10-20 11:06:15
【问题描述】:

当用户关闭 Windows 8 from the Settings charm 时,我的 WPF 应用程序可以通过 SessionEnding 事件检测到。

在选择关闭的情况下,我得到“Session Ending Due To SystemShutdown”

SystemEvents.SessionEnding += SystemEvents_SessionEnding;

private void SystemEvents_SessionEnding(object sender, SessionEndingEventArgs e)
{            
    Trace.WriteLine("Session Ending Due To " + e.Reason);           
}

Shutdown 调用 SessionEnding,但 Restart 不调用

但是当用户选择重启时,不会调用SessionEnding!

在 Windows 8 中检测重启意图

  • 怎么做?

【问题讨论】:

    标签: c# .net windows winapi shutdown


    【解决方案1】:

    他们在这里说,通过观察 WM_EndSession 消息,您应该能够观察重新启动:http://www.autoitscript.com/forum/topic/94616-detect-windows-shutdownlogoffrestart-event/

    您还需要在 WPF 应用程序中挂钩到 WndProc:How to handle WndProc messages in WPF?

    【讨论】:

    • 我现在也能够在 SessionEnding 事件中正常重启,但不确定我的代码发生了什么变化..
    • 很高兴听到你修复它!
    猜你喜欢
    • 2017-02-26
    • 1970-01-01
    • 1970-01-01
    • 2013-03-07
    • 1970-01-01
    • 2012-03-27
    • 1970-01-01
    • 2010-11-02
    相关资源
    最近更新 更多