windows - Intercepting WM_ENDSESSION message -


is possible intercept wm_endsession message prevent application receiving it?

i'd command application perform additional action before windows reboots or shuts down, , it's not possible configure application way.

the application screen recorder software, , throws away video when windows shuts down. need prevent , save video.

is possible intercept wm_endsession message prevent application receiving it?

technically yes, using message hook setwindowshookex(). depending on hook used, can modify (not discard) messages messages, such wm_null. however, in case of wm_endsession, notification, not request, windows still going continue shutting down no matter applications message.

i'd command application perform additional action before windows reboots or shuts down, , it's not possible configure application way.

the application screen recorder software, , throws away video when windows shuts down. need prevent , save video.

so, don't want avoid wm_endsession, want delay other app processing until after action performed first.

the best option contact recorder author , request feature added save video on system shutdown.

beyond that, msdn says following:

application shutdown changes in windows vista

by default, applications without visible top-level windows given 5 seconds handle wm_endsession before being terminated.

if application may need more 5 seconds complete shutdown processing in response wm_endsession, should call shutdownblockreasoncreate() in wm_queryendsession handler, , promptly respond true wm_queryendsession not block shutdown. should perform shutdown processing in wm_endsession handler.

this way, windows treat application if had visible top-level windows , give 30 seconds handle wm_endsession.

so, try using message hook intercept wm_queryendsession , have call shutdownblockreasoncreate() , return immediately, intercept wm_endsession invoke video saving action , call shutdownblockreasondestroy() when finished. assuming, of course, recorder throwing video away in reply wm_endsession , not wm_queryendsession.

see msdn more info how these 2 messages handled windows:

shutdown changes windows vista


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -