10-06-2009 02:52 PM
Colleagues,
I've got small trouble by closing application during logging off (M$ Windows).
My goal is quite easy: when user chooses "Log Off" (or Turn Off PC) in Windows, then he should be able to save some data (opened files, etc).
So, I have added Application Close? Event, then connect "Discard" to TRUE. So far it works - this event fired by logging off, so I'm able to display dialogs if necessary and so on:
The problem is following - after few seconds Windows will show the message "Ending Program. Please Wait..." with progress bar:
The question is - how can I avoid this dialog above from Windows?
Thank you in advance,
Andrey.
PS
I know already about HungAppTimeout, WaitToKillAppTimeout and AutoEndTasks keys in HKCU\Control Panel\Desktop...
10-07-2009 06:53 AM
It seems to be no way to avoid this dialog as I wanted under Windows XP (but seems to be possible with Windows Vista or Windows 7).
The only way it to set HungAppTimeout, WaitToKillAppTimeout and AutoEndTasks keys to more or less acceptable settings:
Just for information:
if AutoEndTasks set to 1 (default is zero), then dialog will not appear, but application will be killed after HungAppTimeout milliseconds.
if AutoEndTasks = 0, then dialog will appear after HungAppTimeout ms and progress bar will be displayed for WaitToKillAppTimeout milliseconds.
Links:
Describing Windows XP and Vista Shutdown in Application context
Application Shutdown Changes in Windows Vista
Closing Timed-Out Applications Without Choosing End Task
ShutdownBlockReasonCreate Function
best regards,
Andrey.
10-07-2009 12:40 PM
Maybe you could call the function 'ShutdownBlockReasonCreate' to prevent windows from shutting down on its own.
When the user logs off, probably you may still intercept the action in the event structure, save all the files you want, call the function 'ShutdownBlockReasonDestroy' and then shutdown windows programmatically.
10-08-2009 03:20 AM
Gyc wrote:
Maybe you could call the function 'ShutdownBlockReasonCreate' to prevent windows from shutting down on its own.
Sure, ShutdownBlockReasonCreate Function is exactly what I needed. The only problem - this function is not available in Windows XP.
Andrey.
10-08-2009 08:03 AM
This seems strange.
When I shutdown my pc with Outlook still open, I get a window telling me that I must first close Outlook and the PC does not shutdown, so the mechanism must exist also in windows XP. Maybe these links can help:
http://blogs.techrepublic.com.com/window-on-windows/?p=644&tag=nl.e064
http://www.addictivetips.com/windows-tips/prevent-log-off-and-shutdown-of-a-windows-xp-computer/
10-08-2009 08:15 AM
This seems strange.
When I shutdown my pc with Outlook still open, I get a window telling me that I must first close Outlook and the PC does not shutdown, so the mechanism must exist also in windows XP. Maybe these links can help:
http://msdn.microsoft.com/en-us/library/aa376630(VS.85).aspx\
http://blogs.techrepublic.com.com/window-on-windows/?p=644&tag=nl.e064
http://www.addictivetips.com/windows-tips/prevent-log-off-and-shutdown-of-a-windows-xp-computer/
10-08-2009 08:35 AM
Gyc wrote:This seems strange.
When I shutdown my pc with Outlook still open, I get a window telling me that I must first close Outlook and the PC does not shutdown, so the mechanism must exist also in windows XP.
Getting window or dialog is not the problem (see example above). Block shutdown is also not problem.
The real problem is avoidin the message above in WindowsXP.
Try to shutdown your PC with opened Word or Excel with unsaved files - then dialog with asking about unsaved files is coming. Now wait 5 seconds. Then you will see the message with progress bar (if you have default registry keys).
Andrey.