Thomas Hruska wrote: > Lennie De Villiers wrote: > >>Hi, >> >>How can I know if MS Windows is shutting down / restarting and delay the >>process? >> >>I’m busy with an application where the user must book-in always before >>shutting down the computer for the day. So the process is: If MS Windows is >>shutting down/restart my application must come up asking for the user to >>book-in first, after book-in the shut down process can continue. >> >>I’m looking for a solution that will work with all versions of MS Windows >>(2000/NT/XP) >> >>Using Delphi 6 EE >> >>Kind Regards, >>Lennie De Villiers > > > Windows broadcasts a message (WM_QUERYENDSESSION) to all top-level > windows when a shutdown begins. ExitWindowsEx() initiates the shutdown. > Because the message is broadcast using SendMessage(), you can suspend > the shutdown process until the user finishes interacting with your > application by manually pumping window messages. When the user is done, > exit the manual message pump and return TRUE to the caller to let the > shutdown continue.
Erk...I just remembered something. Windows 2000/XP might cause problems in this regard. When a shutdown occurs and an application doesn't shutdown within a specific amount of time, Windows kills the application, but not until a fairly lengthy timeout takes place (complete with a dialog box and a progress indicator). Depending on how finicky Windows is that you return the message quickly, you may end up having to return FALSE and then notify the user that the "system shutdown was cancelled because a book-in must take place first". If you could determine the difference between shutdown and reboot, you could cancel the shutdown, save the status of what the user wanted to do (shutdown, reboot, or log off), and then re-initiate it later. Unfortunately, there is no way to tell the difference between shutdown and reboot. Also, because you are making a "shutdown-dependent" application, be sure to make sure your application works as expected when doing "fast user switching" under XP. -- Thomas Hruska CubicleSoft President Ph: 517-803-4197 VerifyMyPC v1.0: "A stable PC is a happy PC." Learn more, take the tour, and download: http://www.CubicleSoft.com/VerifyMyPC/ ----------------------------------------------------- Home page: http://groups.yahoo.com/group/delphi-en/ To unsubscribe: [EMAIL PROTECTED] Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/delphi-en/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/

