Winforms password protection

I have a simple WinForms application running in the system tray. Is it possible to protect the password from closing the program if the user tries to close it from the Task Manager?

Ideally, I want the user not to close the process, but if windows are reloaded, I want it to close without prompting. Very similar to antivirus software.

+3


source to share


3 answers


If the user has the correct permissions, they will be able to kill your process from the Task Manager.

This suggests that @fujiFX mentions the FormClosing event in his comment - a good start and better than nothing.



The FormClosing event occurs when the form is closed. When the form is closed, it is removed, freeing all resources associated with the form. If you cancel this event, the form remains open. To cancel the closing of the form, set the passed event handler for the Cancel

FormClosingEventArgs property true

.

0


source


It's tricky to do, but you can create two applications, one as the main program and two as the helper. If the assistant is killed, the main application restarts it. If the main application is killed, the helper will restart the main application.



0


source


You can do this check in the YourService.Stop method (assuming you are using a Windows service, thus inheriting from ServiceBase), but as far as I know, you cannot prevent the user from killing the process just to close the application (two different things in Windows).

-1


source







All Articles