By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,510 Members | 1,810 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,510 IT Pros & Developers. It's quick & easy.

i dont want to close my application at any cost inC#

Shafi hashmi
P: 14
hi guys i am creating a windows application in C#.

I don't want user to close my application until windows is running.

if user press CTR+ALT+DEL and want to close my application i dont want to let him do

how it is possiable in C#??
What code should i write in C#??

than u in advance..
Feb 12 '11 #1
Share this Question
Share on Google+
3 Replies


Rabbit
Expert Mod 10K+
P: 12,365
You can't stop a user from ending a process. It's a huge security risk.
Feb 12 '11 #2

HaLo2FrEeEk
100+
P: 404
What he said ^^

However, in the interest of information, there is one way I can think of (just don't do it.) You could write your program so that it spawns another process of itself at runtime. Each of these two processes monitors the other, if one is shut down, then a new one is spawned from the one still opened.

Of course, there's no way to really stop the person from killing your process. Let's say your process is called "myProcess.exe", multiple instances of "myrocess.exe" will appear in the task manager, and you can't select multiple items in the task manager, but there's a little-known commandline version of the task manager as well, you can run "tasklist" to get a list of processes, or taskkill to kill a process. If yu had two instances of your program running (one spawned by the other) I could simply run this from the commandline:

taskkill /F /IM myProcess.exe /T

That would kill all of them.

Basically, there's no way to do it that's foolproof, and there's no reason you should want to, respect your user's wishes. If they want to close your program, let them.
Feb 13 '11 #3

P: 4
Window services might help u out...
Feb 13 '11 #4

Post your reply

Sign in to post your reply or Sign up for a free account.