0
votes

I have an Delphi application with log-in form (user and password). When the user is active in the program there is field in an MySQL database that is updated to true when application opened and updated. The field is set to false when the application is closed.

If the application is not closed correctly and the PC is shut down (not closed from main form) how can I change the parameter of log in. Or how can save the status in database or in an inifile so that I can detect if the application is not closed correctly?

1
When you start the application, you'll read from your database value of True, which means that the program didn't saved False when it was finished, and so that something bad happened. - TLama

1 Answers

2
votes

You use the OnClose event of the main form.

When the application starts you record the fact that it's running (i.e. has not yet closed cleanly).
In the OnClose event handler you record the fact that it closed cleanly.
On startup you check the status.
Don't forget to commit the updates to the database or they might not get written.