Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to prevent "wait 20 sec." message on shutdown

Posted on 1998-09-27
6
Medium Priority
?
301 Views
Last Modified: 2010-04-06
Im running a backup program on windows shutdown.
How do I prevent the window message:
"wait 20 second for program to finish".

I am running the backup in a FormCloseQuery
and want windows to shoutdown when my backup i done.
0
Comment
Question by:EEsep
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 1

Expert Comment

by:duke_n
ID: 1340976
didn't get ya.
tell more
0
 
LVL 10

Accepted Solution

by:
viktornet earned 600 total points
ID: 1340977
Instead of OnCloseQuery() use the WMQUERYENDSESSION which will run your code when windows shuts down.......
public
  procedure TForm1.wmQueryEndSession(VAR Msg: TWMQueryEndSession);
    message WM_QueryEndSession;

procedure TForm1.wmQueryEndSession(VAR Msg: TWMQueryEndSession);
begin
  Inherited;
        //Do the process of closing the brocess of backing up stuff....
        Halt;
        Msg.Result := 1;
end;

Regards,
Viktor Ivanov
0
 

Author Comment

by:EEsep
ID: 1340978
Thanks - your solution lets windows shutdown - but the
"wait 20 second for program to finish" message still shows.

Is there any way to prevent that message from showing?


0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Expert Comment

by:viktornet
ID: 1340979
Tell me the Caption of the window ....

When the Dialog box shows to show you that message it's got a Caption, like the name of the window.....like 'Untitled - Notepad'

Tell me that name and it will do it.....

in OnTimer() of some timer.....
var
  H : HWND;
begin
  H := FindWindow(nil, 'TheCaptionOfTheWindow');
  if H <> 0 then
    SendMessage(H, WM_CLOSE, 0,0);
end;

Regards,
Viktor Ivanov
0
 

Author Comment

by:EEsep
ID: 1340980
The caption of the windows message is the same as on my application.

How do I close the correct window?


0
 
LVL 1

Expert Comment

by:pjdb
ID: 1340981
This message is due to the backup that is longer than 20 seconds. To solve it, just trap the OnCloseQuery, cancel the close of windows, do the backup and then close windows. The following code can do it :

in the begining of the form declaration put :
Const
  WM_Backup=WM_User + 1; //window message to ask for the bakup to be done

in the form declaration add :
BackupDone:Boolean;  //true if the backup has been done
procedure DoBackup; message WM_Backup;  //do the backup

in The onShow event of the main form add :
BackupDone:=False  //indicate that the backup has not been done

in the OnCloseQuery of the main form add :
if not BackupDone Then  //test if the backup has been done
Begin  //backup not done -> cancel the close and launch the backup
  CanClose:=False;  //cancel the close of the application (and of windows)
  SendMessage(Handle, WM_Backup, 0, 0); //start the backup via a message (this procedure will end so there will no message on 20 seconds...)
End;

Then add the procedure :
procedure MyForn.DoBackup;
Begin
  Try
//  Do The Backup or anything you want here
  Finally  //no error occur
    BackupDone:=True;  //indicate that the backup has been done -> disable the close trapping
    ExitWindowsEx(EWX_POWEROFF);  //shutdown the computer
  End;
End;

NB : If you want to support windows NT, you have to change the process properties to be able to ask for the system to shut down. If you want this code, just let me know.

JDB
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question