Prevent users from logging out of a Windows application through system hotkeys

I am working on a pre-cash register expression. We need to prevent users from abandoning the application using the keyboard shortcuts Alt + Esc, Ctrl + Alt + Del or Alt + Tab, and we will provide a separate custom hotkey to exit the application. The application will be full-screen and without a close button. I already made a full screen without a cross button, but got stuck by turning off the low-level hotkeys. How to do it in C #? Appreciate any help or alternative methods (i.e., Establishing user rights to prevent the star menu / task manager or any other alternative to achieve the goal).

Edit: we use WinForms. The application will work in Windows XP / Vista / 7.

+4
source share
1 answer

There is no direct way to avoid the standard behavior of Windows. A Windows user should be able to kill applications. If the application does not obey, the system forcibly kills the application.

However, there are a few tricks often used by virus writers, here are some (not extensive) ones:

  • Disabling all system hot keys is relatively trivial, but Ctrl-Alt-Del is not one of them. Check out this excellent code project article with a sample application.
  • Create a DLL and add yourself to other processes that are vital to the system. Ease of execution, but make sure that you port the application from .NET to stand-alone C ++ or another language, you do not want the system processes to depend on the version of .NET you are loading.
  • Instead of a dll sentence, you can create something like a shell extension with a library like this one that allows you to continue to use. NETWORK. It is not intended for this kind of thing, but it forces the user to kill explorer.exe to get rid of your application.
  • Create a service that can interact with the desktop. Limit the rights of the service by conventional means, which essentially has the same effect as preventing users from killing your application using the methods you mention.
  • Obviously, you should cancel any message WM_CLOSE , WM_EXIT or WM_KILL and just continue to live.
  • Use a desktop application, this is what most anti-virus scanners use: if you kill one process, the sentinel will restart it. If you kill the sentry, it should be restarted in the main application. Bad behavior, but it works.

But, general advice: do not do this. Allow your users to potentially kill the program if necessary, otherwise it will be very difficult to perform any maintenance. The only "supported" way is services where you can allow special users to stop your service and cannot be stopped through the task manager.

+5
source

All Articles