The WM_QUERYENDSESSION is only meant for you to popup a confirm save, cancel type dialogbox. All lengthy code should be run here, though be warned that Windows can still kill application that takes too long to handle message (the user could get the "application not responding message"). Limit your processing to 5 seconds or less. It is not a good time to be updating the database because if Windows decides to pull the rug from under your application, you could end up with a corrupt database.
The WM_ENDSESSION message is purely a notification message, and Windows can shutdown at anytime after you receive the message. Its purpose is solely to tell your application that it should not do any more processing. ----- Original Message ----- From: "Steve Aish" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, January 30, 2004 11:43 AM Subject: Re: [DUG] Running events on shutdown > Update: > > After more investigation it seems that these do actually work on shut down (but not log off). If I put in a message box in the WMQueryEndSession procedure it pops up. Also the other ones I mentioned. The problem is that the procedure that needs to run takes approx half a second to 1 � seconds to run. If there are 3 other programs running the procedure has enough time to searchthe database, update a record and close (yay). If there is nothing else open windows closes before the code has a chance to run so therefore it doesn't seem to work. > > So > > 1. Is there a similar thing that works for Log Off (WMQueryLogOff or something???) > > 2. Is there a way I can say WAIT to the shut down of windows? I know I can say STOP but that doesn't really help me. I still want the PC to shut down. Just not as fast... > > Steve > > >>> [EMAIL PROTECTED] 30/01/2004 11:09:32 a.m. >>> > I have a program that runs some code when you close it down. Basically > to tell the server that it is shut down properly. > > I also want this code to run if the user logs off or shuts down the PC > without closing down the program. > > I am having heaps of trouble getting this to work. I have searched the > internet and found a couple of ways of doing this but none actually seem > to work for me. > > 1. use the OnCloseQuery on the main form. > > Using this I can actually stop windows closing down (yay) but if I put > code in here it doesn't seem to run before shutting the computer down. > > 2. Capture the WMQueryEndSession message from windows > > Seems to either > a : Run the tidy up code and stop windows from shutting down > or > b: Let windows shut down but don't run the code > > Does anyone have any pointers on this? Any ideas what I might be doing > wrong. The program runs over a sockets connection using midas... All I > am trying to do is run a couple or queries (search for a record - then > update this record) _______________________________________________ Delphi mailing list [EMAIL PROTECTED] http://ns3.123.co.nz/mailman/listinfo/delphi
