I want to put inside a software the necessary codes for it to disable Windows (Xp, Vista, specially 7 and sucessors) hotkeys that could allow the user to get away from the software.
Details:
- The commands must be valid only while the software is running; when its not running, Windows hotkeys must be enabled (so: if the user starts the software, the hotkeys are disable; if he closes it, must be re-enabled).
- I don’t want to disable all windows hotkeys (some key hotkeys such as ctrl+alt+del must still be operational), so solutions such as some sort of windows configuration that disable all hotkeys are useless for me. I must be capable of specifically select which hotkeys I want to continue working and which I don’t.
- The “hotkey” nickname includes the Windows button.
- The code must be either using C++ or Windows functions.
- Preferetially without requiering to terminate explorer.exe.
I did look at a post here in stackoverflow that had a very similiar case as mine (Prevent users from quitting a windows application via system hotkeys), but as far as I understood nether of the solutions presented were applicable to my specific situation, and I didn’t find anything in the web as well.
Ok, I got how to do it. The code is able to create a sistem-wide hook without DLL using a low level keyboard hook. Here is the code (better that explaining)(using Qt):
This last function don’t need any declaration in the .h or in the .cpp file. It blocks inputs of Ctrl, Windows Key and Alt. The other two must be placed respectively in the functions where the user wants to begin the key disabling and when he want it to stop.
Thanks,
Momergil.