戒烟通过系统热键Windows应用程序prevent用户 [英] Prevent users from quitting a windows application via system hotkeys

查看:223
本文介绍了戒烟通过系统热键Windows应用程序prevent用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在,直到/现金出纳机的应用程序。我们需要prevent的用户通过使用Alt + Esc键,按Ctrl + Alt + Del组合键或Alt + Tab键等组合退出应用程序,我们将提供一个单独的自定义热键在quiting。该应用程序将是全屏,无任何关闭按钮。我已经做了全屏无交叉按钮部分,而是坚持使用禁用低的系统级热键。我如何在C#中做到这一点?任何帮助或替代方法(即用户组权限设置为prevent星级菜单/任务管理器或任何其他的替代方案要达到的目标)是AP preciated。

I've been working on a till/cash-register application. We need to prevent the users from quitting the application by using Alt + Esc, Ctrl + Alt + Del or Alt + Tab etc combinations and we'll be providing a separate custom hotkey for quiting. The application will be full-screen and without any close button. I've already done the full screen no cross button part but stuck with disabling the low system level hotkeys. How do I do this in C#? Any help or alternative methods (ie. setting up user group permissions to prevent star menu/task manager or any other alternative to achieve the goal) are appreciated.

编辑:我们正在使用的WinForms。该应用程序将在Windows XP上运行/ Vista / 7的。

We're using WinForms. The application will run in Windows XP/Vista/7.

推荐答案

有没有直接的方法从Windows的标准行为逃脱。的Windows用户必须具有的可能性杀应用程序。如果应用程序不服从,系统将强制杀的应用程序。

There is no direct way to escape from the standard behavior of Windows. A user of Windows must have the possibility to kill applications. If the application doesn't obey, the system will force-kill the application.

然而,也有一些技巧,经常被病毒作者使用的,这里有一些(不是广泛的):

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

  • 如果不允许所有的系统热键是比较琐碎,但按Ctrl-Alt-Del组合是不是在他们之中。查找这个优秀的code项目文章与样品应用程序。
  • 在建立一个DLL注入自己在那些对系统至关重要的其他进程。这很容易做到,但要确保你的端口应用程序从.NET到独立的C ++或其他语言,你不希望系统进程依赖于.NET那的的版本,你的负载。
  • 在代替DLL的建议,你可以创造这样一个外壳扩展用类似这样的库这个它允许你继续使用.NET。这并不意味着这种事情,但它迫使用户杀的Explorer.exe 来摆脱你的应用程序。
  • 创建可与桌面交互的服务。通过正常手段,本质上具有不允许用户通过你提到的方式来杀死你的应用程序的效果相同限制服务的权利。
  • 显然,你应该取消任何 WM_CLOSE WM_EXIT WM_KILL 消息,只是继续活。
  • 使用定点应用程序,这是大多数病毒扫描程序使用的:如果你杀了一个进程,哨兵将重新启动。如果你杀了哨兵,它应该由主应用程序重新启动。不良行为,但作品。
  • Disallowing all system hotkeys is relatively trivial, but Ctrl-Alt-Del is not amongst them. Look up this excellent code-project article with a sample application.
  • Build a DLL and inject yourself in other processes that are vital to the system. Easy to do, but make sure you port your application from .NET to standalone C++ or other language, you don't want system processes to be dependent on the version of .NET that you load.
  • In lieu of the dll-suggestion, you can create something like a shell extension with a library like this one which allows you to continue using .NET. It's not meant 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. Restrict the rights of the service by normal means, which essentially has the same effect of disallowing users to kill your app through the ways you mention.
  • Obviously, you should cancel any WM_CLOSE, WM_EXIT or WM_KILL message and simply continue "living".
  • Use a sentinel application, this is what most virus scanners use: if you kill one process, the sentinel will restart it. If you kill the sentinel, it should be restarted by the main app. Bad behavior, but works.

不过,一般的建议是:不这样做。允许如果需要,您的用户可能会杀程序,否则将很难做任何维修。唯一的支持的方式就是通过服务,在这里你可以允许特定用户停止你的服务,它无法通过任务管理器停止。

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

这篇关于戒烟通过系统热键Windows应用程序prevent用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆