LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Application Instance Close? - How to avoid Windows Dialog by Log Off?

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:

 

 Snippet.png

 

The problem is following - after few seconds Windows will show the message "Ending Program. Please Wait..." with progress bar:

 

 ScreenShot.png

 

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...

 

0 Kudos
Message 1 of 7
(6,610 Views)

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:

 

Registry.png

 

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

AutoEndTasks

HungAppTimeout

WaitToKillAppTimeout

ShutdownBlockReasonCreate Function

 

best regards, 

 

Andrey.

Message 2 of 7
(6,574 Views)

 

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.

 

 

 

 

0 Kudos
Message 3 of 7
(6,546 Views)

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.

0 Kudos
Message 4 of 7
(6,528 Views)

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://www.shutdownlock.com/ 

 

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/


 

 

 

 

0 Kudos
Message 5 of 7
(6,497 Views)

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://www.shutdownlock.com/ 

 

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/


 

 

 

 

0 Kudos
Message 6 of 7
(6,494 Views)

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.

 

0 Kudos
Message 7 of 7
(6,488 Views)