Task Manager End task

Hi,

I have developed an application using D7 that monitors time used on the computer.
When a user uses Windows Task Manager to close my application while my application is in the running state (i.e. the status is not "Not responding", it is still "Running") does Windows send a message to my application that I can respond to and possibly cancel the close command.
I will be glad to have some information on this issue.

Thank you
martbaseAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
TNameCommented:
You could also/additionally use a second small process that just checks regurarly if the main application is still running. Logging the status (e.g. every minute) would also be worth considering.
0
 
martbaseAuthor Commented:
Thanks a lot TName,

I found the link to PAQ very helpful especially Madshi's solution which is quite elegant. My application is multi-threaded so I believe his solution will be perfect me. My only concern is that when the application gets terminated using Task manager, will the application handle in the call to "WaitForSingleObject(Application.Handle, INFINITE)" still be valid? Could I possibly get a working example that has already been tested. Also if the Application object is still valid I have this idea that I could relaunch the application since I can get its filename from the application object! Is there any danger in launching my application from one of its threads?
0
All Courses

From novice to tech pro — start learning today.