-
January 22nd, 2009, 11:45 PM
#1
Endtask Application...
Is there any way to avoid my application getting killed through task manager... or a way to detect that task manager is going to terminate the application....
-
January 23rd, 2009, 12:09 AM
#2
Re: Endtask Application...
I think that task manger can kill your application in any case... The only things that I can think to avoid this is to make tm believe your is a system critical task; in that case it would refuse to terminate the task.
But why you want to exert such a control over the user? I think this violates programming ethics...
To detect if your application is about to be terminated normally there are ways, like override virtual function ExitInstance in your CWinApp derived class, or handling the message WM_CLOSE in the MainFrame or other fundamental window of the app, but I don't know exactly if these method works also with task manager termination, that follows not the regular terminating way, but a brute force approach...
I delegate this to more expert people in this forum
- Buzzyous -
-
January 23rd, 2009, 02:31 AM
#3
Re: Endtask Application...
Originally Posted by LOOSER_007
Is there any way to avoid my application getting killed through task manager... or a way to detect that task manager is going to terminate the application....
Why would you like to do that? That sounds like some malicious application.
-
January 23rd, 2009, 02:52 AM
#4
Re: Endtask Application...
Yes but why do you need to it?
-
January 23rd, 2009, 03:32 AM
#5
Re: Endtask Application...
Actually in my application m communicating with some drivers thus before killing the application i want to store some info(into a file or reg) so that i can restore the info on next relaunch of the application....
-
January 23rd, 2009, 06:53 AM
#6
Re: Endtask Application...
There can be many legitimate reasons to be notified before the app closes - even by task manager, and here's one basic approach (it won't catch all possible ways, but nearly all).
Handle the WM_CLOSE message in your frame window. That message is sent when the user clicks the X in the top right of the app, or when they use Alt-F4, or from the Task Manager (applications tab) when they choose End Task.
Hope that helps.
Be sure to rate those who help!
-------------------------------------------------------------
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
-
January 23rd, 2009, 08:27 AM
#7
Re: Endtask Application...
Originally Posted by LOOSER_007
Actually in my application m communicating with some drivers thus before killing the application i want to store some info(into a file or reg) so that i can restore the info on next relaunch of the application....
So put that in the normal shutdown code. If the use chooses to terminate your app through task manager, that's their prerogative and more than likely they'd have a good reason for it.
If it were my computer, any program I found that was making a deliberate attempt to hide or subvert my control would be removed immediately. That's just not how legitimate programmers write code. You should stop thinking like that immediately or find another board to ask those questions on.
-
January 23rd, 2009, 01:15 PM
#8
Re: Endtask Application...
Originally Posted by GCDEF
If it were my computer, any program I found that was making a deliberate attempt to hide or subvert my control would be removed immediately. That's just not how legitimate programmers write code.
While I agree that any attempt to hide or subvert your control is not a good thing, I would not say that a legitimate intercept of a task manager shutdown request is "not how a legitimate programmer" would write code.
Several of our applications process very large amounts of data - sometimes requiring more than 20 hours to process. By catching the WM_CLOSE (which catches the X button and also a shutdown request from task manager), we can warn the user through a pop-up that the processing is incomplete and they need to stop the processing before closing - but then we also provide a Cancel button to gracefully shut down the processing.
In any event, if you handle the WM_CLOSE for your purpose, you should warn the user, and give them the option to gracefully shutdown by executing your cleanup code, or to ignore the shutdown request.
Be sure to rate those who help!
-------------------------------------------------------------
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|