问题
I am creating a desktop application using the JDesktopPane. I'm almost complete, but when I press ctrl + alt + del, it leaves my application. How can I prevent that action?
回答1:
Fact is Alt+Ctrl+Del never actually entering your application. Os traps Alt+Ctrl+Del before it is send to your application. So you can't trap it.
回答2:
Alt+Ctrl+Del cannot be overridden. It is a security feature.
回答3:
You cannot do that. The behavior of Alt+Ctrl+Del is enforced by the operating system, for good reasons: it makes sure that you can always bail-out of a faulty application.
回答4:
http://www.codeproject.com/KB/winsdk/AntonioWinLock.aspx
lists several possibilities, from disabling the taskmanager to injecting keyboard hooks. But I doubt there's some built-in java functionality for that.
回答5:
You can disable the task manager by setting alwaysOnTop to true and when they signout have your program cancel the signout. However, there is nothing against powering off your machine.
回答6:
What I have done is add a temporary file to the startup folder and then using a forced sign out when they hit they hit control ALT delete in a shutdown hook. Also, I would set the GUI to alwaysOnTop. However, when they log back in make sure you delete the temp running file. This, way if they sign out and cancel it, they will not be able to, and the program will still run.
来源:https://stackoverflow.com/questions/2616341/disable-the-ctrl-alt-delete-event-through-java-program