VC截获系统注销时候的消息

使用WH_CALLWNDPROC类型钩子,回调函数如下:
LRESULT CALLBACK MyProc(int code, WPARAM wParam, LPARAM lParam)
{
switch (((CWPSTRUCT*)lParam)->message)
{
case WM_QUERYENDSESSION:
{
switch( ((CWPSTRUCT*)lParam)->lParam )
{
case ENDSESSION_LOGOFF:
{
FILE *pFile = NULL;
((CWPSTRUCT*)lParam)->message = 0;
AfxMessageBox(TEXT(“log off”));
return 0;
}
break;
}
}
}
return ::CallNextHookEx(g_hMessage, code, wParam, lParam);
}
转载请说明出处:http://blog.csdn.net/mycaibo

你可能感兴趣的:(File,null,callback)