Thanks
Achmed
Hi,
Try to create a hook into the windows message WM_QUERRYENDSESSION
so you can have a bit more head start, otherwise the system could
assumes an unresponsive process is dead, and takes actions against it.
remember every application gets the message WM_QUERYENDSESSION,
and in your reply you can say "yes" or "no" but your answer is only
one vote, the first application to respond to this message stops the
polling by windows. Also, use the API SetProcessShutdownParameters()
to set the shutdown parameters for the current calling process.
You need to use a system-wide hook, for example, WH_CALLWNDPROC to
monitor messages being sent, and WH_CALLWNDPROCRET to monitor the
messages handlers returning, and a hook procedure in a .DLL file.
Try to use the following APIs:
SetWindowsHookEx()
CallNextHookEx()
UnhookWindowsHookEx()
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/wm_queryendsession.asp
Kellie.
It should be easy to hook WM_CLOSE and WM_SYSCOMMAND(SC_CLOSE), but
hooking the close entry on the file menu could be a bit tricky. If you
examine the messages initiated by that command, you may find the it's easy
enough to hook WM_COMMAND with the appropriate parameters.
--
- Gary Chanson (Windows SDK MVP)
- Abolish Public Schools