Click here to Skip to main content
15,881,898 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to use c# programe to prevent the other process closed by it's close button or closed by Task Manager?
i searched some information about hook,but don't know whether it can reach my need.
can anybody give me demo?
thanks!
Posted
Comments
Thomas Daniels 24-Jun-13 9:15am    
In Windows Forms?
xuyunhai 24-Jun-13 9:17am    
yes,windows form

You can prevent the closing of a program using hooking. I used to do that back in VB6. If you don't get any suggestions in .NET, I'll try to work out a sample for you tomorrow.

But you cannot prevent a process from being closed by the task manager or Windows shutdown. If you could, it would be possible for you to completely prevent windows from working properly, and nobody is interested in that. Not even you when you're attacked by angry users who cannot close their OS.
 
Share this answer
 
Comments
xuyunhai 24-Jun-13 9:46am    
i usually write program by c# ,but i can read vb program,you can give me demo and wrap it to dll,thanks!
Johnny J. 25-Jun-13 5:05am    
Did a demo for you. Have a look here:
http://www.codeproject.com/Articles/611358/How-to-use-PInvoke-to-disable-the-close-button-on

(PS: It was a lot of work, so if it helps you, please upvote the solution AND mark it as solved)
xuyunhai 25-Jun-13 8:38am    
brother,can't download "Download sample demo - 44.7 KB",maybe the url is denied
Johnny J. 25-Jun-13 8:44am    
That's strange - I just checked and it worked fine for me. I can also see that there have been 12 other downloads. Could you try again, please?
xuyunhai 25-Jun-13 9:13am    
it's ok now,thank you very much,thank you!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900