如何检测的Windows是否关闭或重新启动 [英] How to detect whether Windows is shutting down or restarting

查看:223
本文介绍了如何检测的Windows是否关闭或重新启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道,当Windows正在关闭,它发送一个 WM_QUERYENDSESSION 消息给每个应用程序。这使得它很容易当Windows正在关闭检测。但是,是否有可能知道,如果电脑要关闭电源或者是要重新启动Windows的关机后。

I know that when Windows is shutting down, it sends a WM_QUERYENDSESSION message to each application. This makes it easy to detect when Windows is shutting down. However, is it possible to know if the computer going to power-off or is it going to restart after Windows has shutdown.

我不是特别乐观,考虑到在MSDN文档有此说关于 WM_QUERYENDSESSION :......这是不可能的,以确定哪些事件正在发生,但计算器累计聪明从来没有停止给我带来惊喜。

I am not particularly hopeful, considering the documentation at MSDN has this to say about WM_QUERYENDSESSION: "...it is not possible to determine which event is occurring," but the cumulative cleverness of stackoverflow never ceases to amaze me.

推荐答案

从的这里

您可以阅读DWORD值
  HKCU \\软件\\微软\\的Windows \\ CurrentVersion \\ Explorer中\\关机
  设置,以确定用户什么
  最后从Shut选择向下
  对话框。

You can read the DWORD value from "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shutdown Setting" to determine what the user last selected from the Shut Down dialog.

迂回的解决方案的一点,但它应该做的伎俩。

A bit of a roundabout solution, but it should do the trick.

这篇关于如何检测的Windows是否关闭或重新启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆