Windows关机检测
来源:互联网 发布:阴阳师 御魂强化数据 编辑:程序博客网 时间:2024/05/03 17:11
//这个.h中没有, 定义
#define ENDSESSION_CLOSEAPP 0x1
#define ENDSESSION_CRITICAL 0x40000000
LRESULT CTestSystemPowerOffDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
// TODO: Add your specialized code here and/or call the base class
if(WM_ENDSESSION == message)
{
AfxMessageBox("WM_ENDSESSION");
BOOL bEnd = (BOOL)wParam;
if((bEnd) && (ENDSESSION_CLOSEAPP == lParam))
{
AfxMessageBox("the session is being ended");
}
else if((bEnd) && (ENDSESSION_CRITICAL == lParam))
{
AfxMessageBox("The application is forced to shut down");
}
else if((bEnd) && (ENDSESSION_LOGOFF == lParam))
{
AfxMessageBox("The user is logging off.");
}
/************************************************************************/
/* WM_ENDSESSION
/* 只要符合(WM_ENDSESSION && bEnd), 我们就可以认为计算机关机了或注销了
/* 这个时候,不能做的就别做了(例如: 去访问驱动程序, 或调用第三方的API),
/* 该保存的就保存.
*/
/************************************************************************/
}
return CDialog::WindowProc(message, wParam, lParam);
}
资料来源:http://msdn.microsoft.com/en-us/library/aa376889%28VS.85%29.aspx
The WM_ENDSESSION message is sent to an application after the system processes the results of the WM_QUERYENDSESSION message. The WM_ENDSESSION message informs the application whether the session is ending.
A window receives this message through its WindowProc function.
LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // end-session option
LPARAM lParam // logoff option
);
Parameters
- hwnd
A handle to the window.
- uMsg
The WM_ENDSESSION identifier.
- wParam
If the session is being ended, this parameter is TRUE; the session can end any time after all applications have returned from processing this message. Otherwise, it is FALSE.
- lParam
This parameter can be one or more of the following values. If this parameter is 0, the system is shutting down or restarting (it is not possible to determine which event is occurring).
Value Meaning - ENDSESSION_CLOSEAPP
- 0x1
If wParam is TRUE, the application must shut down. Any data should be saved automatically without prompting the user (for more information, see Remarks). The Restart Manager sends this message when the application is using a file that needs to be replaced, when it must service the system, or when system resources are exhausted. The application will be restarted if it has registered for restart using the RegisterApplicationRestart function. For more information, see Guidelines for Applications.
If wParam is FALSE, the application should not shut down.
- ENDSESSION_CRITICAL
- 0x40000000
The application is forced to shut down.
- ENDSESSION_LOGOFF
- 0x80000000
The user is logging off. For more information, see Logging Off.
Note that this parameter is a bit mask. To test for this value, use a bit-wise operation; do not test for equality.
Return Value
If an application processes this message, it should return zero.
Remarks
Applications that have unsaved data could save the data to a temporary location and restore it the next time the application starts. It is recommended that applications save their data and state frequently; for example, automatically save data between save operations initiated by the user to reduce the amount of data to be saved at shutdown.
The application need not call the DestroyWindow or PostQuitMessage function when the session is ending.
- Windows关机检测
- Windows关机技巧谈
- 实现Windows关机程序
- Script: Windows关机
- 如何阻止windows关机?
- Windows关机策略
- Windows关机代码
- Windows 的关机命令
- Windows关机命令
- windows xp 远程关机
- Windows 关机命令
- c++实现windows关机
- Windows Mobile关机代码
- 阻止windows关机
- Windows 关机技巧
- Windows关机方法
- windows远程关机
- windows自动定时关机
- 里程碑 - 上海美国领事馆面签实录
- FreeBSD 如何修改root密码
- 了解自己
- Tomcat 的参数配置及一般问题的解决
- VSTO 为Office已有右键菜单添加自己的菜单项(word,Excel)
- Windows关机检测
- CString 与string 以及char之间的转换
- c++ 思考
- 如何生成一个新的互联网访问接入点
- Fedora下 DirectFB 开发手记(二) 编译测试 DriectFB
- 避免内存泄露
- LINUX---動態獲取ip地址
- Internet Explorer无法打开站点,已终止操作
- 如何自定义控件的显示效果