473,320 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Can I delay windows automatically shuting down my app?

My program gets a WM_QUERYENDSESSION message and asks the user if it is OK
to shutdown.

While he's thinking about it, Windows displays a box saying the program is
not responding, and if not answered shuts down my program.

I need to delay that while until the user answers my program's dialog box.

How does Windows check to see if an app is responding.

Can I either make windows satisfied that my program is responding
or specify a longer time before it displays its box
or increase the time its box is displayed before it automatically shuts down
my app?

Thanks for any help

Jan 16 '07 #1
4 1860
Frank wrote:
My program gets a WM_QUERYENDSESSION message and asks the user if it is OK
to shutdown.

While he's thinking about it, Windows displays a box saying the program is
not responding, and if not answered shuts down my program.
Responding usually means processing messages.
I need to delay that while until the user answers my program's dialog box.

How does Windows check to see if an app is responding.
I think it fires messages to the window and waits for a response. No
response within a reasonable period == not responding. In this case, the
message is WM_QUERYENDSESSION, and that's a problem for you I think,
since the whole point is that you need to delay responding to that
message until later.
Can I either make windows satisfied that my program is responding
or specify a longer time before it displays its box
or increase the time its box is displayed before it automatically shuts down
my app?
One solution is to respond immediately to the WM_QUERYENDSESSION by
returning FALSE (abort shutdown), and then initiate the same kind of
shutdown that had already been initiated once the user has responded to
your message (actually, I'm not sure whether you can work out whether it
was a restart or a plain shutdown).

I don't know of a way to change the OS delay you mention - there may be
a registry key somewhere for it.

Tom
Jan 17 '07 #2
One solution is to respond immediately to the WM_QUERYENDSESSION by
returning FALSE (abort shutdown), and then initiate the same kind of
shutdown that had already been initiated once the user has responded to
your message (actually, I'm not sure whether you can work out whether it
was a restart or a plain shutdown).
Users *hate* that behavior, they expect that if they click logout and walk
away, the computer will be logged off when they come back.

Find some reasonable default behavior, like saving all open files with an
alternate name (append .autosave or .leftopen to the filename). Then, if
the user hasn't responded to your prompt by the timeout, execute the default
behavior and quit.

http://www.microsoft.com/technet/pro....mspx?mfr=true

Note that if AutoEndTasks is set you need to give up on waiting for the user
with time to spare for your own processing or I/O, otherwise your app will
be rudely terminated.
http://www.microsoft.com/technet/pro....mspx?mfr=true
>
I don't know of a way to change the OS delay you mention - there may be a
registry key somewhere for it.

Tom

Jan 17 '07 #3
Seems to me that this should be a common problem.
Many programs ask if you want to save before shutdown
I think, haven't really seen it lately

Thanks
"Tom Widmer [VC++ MVP]" <to********@hotmail.comwrote in message
news:eI**************@TK2MSFTNGP06.phx.gbl...
Frank wrote:
>My program gets a WM_QUERYENDSESSION message and asks the user if it is
OK to shutdown.

While he's thinking about it, Windows displays a box saying the program
is not responding, and if not answered shuts down my program.

Responding usually means processing messages.
>I need to delay that while until the user answers my program's dialog
box.

How does Windows check to see if an app is responding.

I think it fires messages to the window and waits for a response. No
response within a reasonable period == not responding. In this case, the
message is WM_QUERYENDSESSION, and that's a problem for you I think, since
the whole point is that you need to delay responding to that message until
later.
>Can I either make windows satisfied that my program is responding
or specify a longer time before it displays its box
or increase the time its box is displayed before it automatically shuts
down my app?

One solution is to respond immediately to the WM_QUERYENDSESSION by
returning FALSE (abort shutdown), and then initiate the same kind of
shutdown that had already been initiated once the user has responded to
your message (actually, I'm not sure whether you can work out whether it
was a restart or a plain shutdown).

I don't know of a way to change the OS delay you mention - there may be a
registry key somewhere for it.

Tom

Jan 17 '07 #4

"Ben Voigt" <rb*@nospam.nospamwrote in message
news:eZ**************@TK2MSFTNGP02.phx.gbl...
>
>One solution is to respond immediately to the WM_QUERYENDSESSION by
returning FALSE (abort shutdown), and then initiate the same kind of
shutdown that had already been initiated once the user has responded to
your message (actually, I'm not sure whether you can work out whether it
was a restart or a plain shutdown).

Users *hate* that behavior, they expect that if they click logout and walk
away, the computer will be logged off when they come back.
I hadn't thought about that.
I'll look at the sites.

thanks

>
Find some reasonable default behavior, like saving all open files with an
alternate name (append .autosave or .leftopen to the filename). Then, if
the user hasn't responded to your prompt by the timeout, execute the
default behavior and quit.

http://www.microsoft.com/technet/pro....mspx?mfr=true

Note that if AutoEndTasks is set you need to give up on waiting for the
user with time to spare for your own processing or I/O, otherwise your app
will be rudely terminated.
http://www.microsoft.com/technet/pro....mspx?mfr=true
>>
I don't know of a way to change the OS delay you mention - there may be a
registry key somewhere for it.

Tom


Jan 17 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Salty Dog | last post by:
Code: <%Response.Buffer = False%> <HTML> <HEAD> <title>Printing</title> </HEAD> <BODY> <center> <% FilePath = "c:\WUTemp\441817810_receiver.txt"
20
by: Doug Thews | last post by:
I ran into an interesting re-pain delay after calling the Abort() method on a thread, but it only happens the very first time I call it. Every time afterward, there is no delay. I've got a...
6
by: carbon_dragon | last post by:
Ok, so here is the problem. I'm working on a headless server program implemented as a .NET C# Console project. There is a UPS mounted to this server (though not a windows compliant UPS). I can only...
2
by: kishor | last post by:
Hi, I want to perform some actions when windows is shuting down. on stop event is not firing when has some code inside it. Regards, Kishor
1
by: Sebouh | last post by:
Hi guys. I''m curious about what happens when windows shuts down. I have a program running that saves data into a file when the form's closing method is invoked. So when Windows shuts down, does...
2
by: =?Utf-8?B?ZGlncmVnYQ==?= | last post by:
After installing Microsoft Office 2007 + desktop search, Windows explorer began to give me all kinds of errors including a DR Watson, which I haven't seen since installing XP. I found a forum...
5
by: drexlin | last post by:
We have an application that is supposed to run as a service. When someone shuts down the computer, the app is supposed to save the contents of the screen into a file so it can be loaded back up when...
8
by: Craig Williamson | last post by:
I'm trying to write a time delay loop in Borland C 3.1 (for legacy code) which has an accuracy of about 0.1ms. This change is due to a hardware change and the software is now running too fast to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.