Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2009-12

capturing system shutdown

5 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Henry Vermaak
to Chris Jennings: Hi All I'm a newbie to fpc/Lazarus. I have been able to make (in my mind) remarkable…

2009/12/21 Chris Jennings :

Show quoted text 12 lines
--8<-- 1. User opens my program and begins to interact with the data behind the program. 2. User initiates a system shutdown or logoff without closing my program. 3. The system must transfer control to my program that will at this point bring up a dialog suggesting that the user save any changes and close the program. 4. Upon doing #3, the system then continues with shutdown or will acept a new shutdown command. I know that this can be accomplished but have now idea where to start.

Well, for unix systems (or linux, at least) the program will receive a sigterm signal when the system is shutting down. You can catch this signal and do some last minute emergency stuff, but you can't stop the system from shutting down (at least as far as I know).

For example, if you're using vi and you kill it, the next time you try and edit one of the files that were open it will ask you if you'd like to recover (since it sees a tmp file).

Henry

Reply by email

JoshyFun
to Chris Jennings: Hi All I'm a newbie to fpc/Lazarus. I have been able to make (in my mind) remarkable…

Hello Lazarus-List,

Monday, December 21, 2009, 6:01:28 AM, you wrote:

CJ> 1. User opens my program and begins to interact with the data behind the CJ> program.
CJ> 2. User initiates a system shutdown or logoff without closing my program. CJ> 3. The system must transfer control to my program that will at this CJ> point bring up a dialog suggesting that the user save any changes and CJ> close the program.
CJ> 4. Upon doing #3, the system then continues with shutdown or will acept CJ> a new shutdown command.
CJ> I know that this can be accomplished but have now idea where to start.

In Windows world you must handle the WMQueryEndSession message, I had done it in Delphi in the past but never in Lazarus. You can try this Delphi snippet http://delphi.about.com/cs/adptips2000/a/bltip0500_4.htm

Take care that if you show the message but do not answer or cancel the shutdown the system will anyway shutdown thinking that your application is hanged. So the process should be like:

1) Handle message
2) Message is being received
3) Post a message or setup a timer to happend 100 ms after to show the custom message.
4) Answer to message cancelling the shutdown.
5) If you decide to continue with shutdown invoke a programatically system shutdown.

Best regards, JoshyFun

Reply by email

Chris Jennings

Hi All

I'm a newbie to fpc/Lazarus. I have been able to make (in my mind) remarkable headway in starting to develop a cross platform application that will hopefully end up being the begining of a major open source project aimed at the educational community.

I have been able to find a lot of specific information by searching Google and have also received a lot of quality help from members of the Lazarus/fpc community.

Today I have a problem that I can't find any reference to when searching. I need to be able to do this in both a Linux and Win environment.

1. User opens my program and begins to interact with the data behind the program.
2. User initiates a system shutdown or logoff without closing my program.
3. The system must transfer control to my program that will at this point bring up a dialog suggesting that the user save any changes and close the program.
4. Upon doing #3, the system then continues with shutdown or will acept a new shutdown command.

I know that this can be accomplished but have now idea where to start.

Any help or code segments would be much appreciated.

Thanks

Chris Jennings

Reply by email

Luca Olivetti
to Paul Ishenin: Application.OnEndSession executes by this message. Paul Ishenin.

En/na Paul Ishenin ha escrit:

Show quoted text 6 lines
JoshyFun wrote: > In Windows world you must handle the WMQueryEndSession message, I had > done it in Delphi in the past but never in Lazarus. You can try this > Delphi snippet http://delphi.about.com/cs/adptips2000/a/bltip0500_4.htm > Application.OnEndSession executes by this message.

OnQueryEndSession (invoked earlier than OnEndSession) can also cancel the shutdown.

Bye

Luca Olivetti Wetron Automatizaci?n S.A. http://www.wetron.es/ Tel. +34 93 5883004 (Ext.133) Fax +34 93 5883007

Reply by email