LeP - I found no evidence of the 5 second limit you mention.
I don't find the old reference about that (but I take a real applicaton locked and I press the power off button of a PC and this is the time that Windows wait for).
I remember it was related to shutdown procedure that Windows use at that now I know was changed over the time.
I have some win register keys where those times are exposed (there are other for services too), and they came from old defaults:
- HKCU\Control Panel\Desktop\
AutoEndtask
WaittoKillAppTimeout
HungAppTimeout
I tried to delete those and the effects on shutdown are the same. On the new systems these keys are not exposed, you must insert manually if you want to alter the times.
Every users can change the own times, depending on the applications.
By the way, these values were the default in the old times, and not enough for my applications. But with the API proposed Windows acts like I want.
I don't know if Windows, since those keys are not exposed anymore, acts in dinamic way for shutdown.
I will try with different machines and different configuration and loads to view how the shutdown acts.
But, since now what I have done is still working so I don't think to change it.
LeP - But I did note that Windows gives you a dialog offering to kill a slow app after about (?) five seconds.
Yes, the screen propose the name of all applications that slow down the process and also the string that you use in the API I show in the posts.
In Windows that is either WM_QUIT or WM_CLOSE but how to use them ?
WM_CLOSE message is sent to a FORM (or same controls) that should be closed. You can choose to really destroy or not the Form and all childs.
WM_QUIT is send to the Application, I don't know if you can intercept it normally or you must act in other way (I never catch WM_QUIT message).
There are more other messages the are sent to an application during the close process (like WM_DESTROY, WM_NCDESTROY, etc ..), but those no needs to catch too.