
- #HOW TO LOCK COMPUTER WITH KEYBOARD WINDOWS 7 HOW TO#
- #HOW TO LOCK COMPUTER WITH KEYBOARD WINDOWS 7 UPDATE#
- #HOW TO LOCK COMPUTER WITH KEYBOARD WINDOWS 7 CODE#
This is accomplished by passing in the 3 rd parameter of the SetWindowsHookEx() call, the instance handle of the application (and not the library as the documentation states). In my application, I wanted to avoid the use of an external library, so I set the global hook inside my own application (without an external library).
#HOW TO LOCK COMPUTER WITH KEYBOARD WINDOWS 7 CODE#
The DLL is then mapped into the context of every process and can trap the events for each process - that's why hooks are used to inject code into a remote process.

The Microsoft documentation states that global hook procedures should be placed in a separate DLL. To trap the switching task keys, it's necessary to write a global hook. Local hooks can only trap events for your application, while global hooks can trap events for all the running applications. There are two type of hooks: local and global (or system wide) hooks. This can be accomplished with the following code:Ĭopy Code UnhookWindowsHookEx(hKeyboardHook) You can disable all these key combinations (including Ctrl+Alt+Del) by fooling the operating system into thinking the screen saver is running. There are several ways to disable these key combinations. I call system keys all the special key combinations that the operating system (OS) use to switch between tasks or bring up the Task Manager.
#HOW TO LOCK COMPUTER WITH KEYBOARD WINDOWS 7 HOW TO#
To find out how to prevent this unwanted behavior, you have to read the next section. You will see that if you hide the Desktop and the Taskbar, the Start Menu still pops up when you press the Win key or double click the desktop area. If you want just to disable the window, and not hide it, change the ShowWindow() call to EnableWindow(). You can use this technique for any window or control you wish to hide. How do I know that the Taskbar class name is " Shell_TrayWnd" or that the Start Button id is 0x130? I used the Spy++ utility that comes with Microsoft Visual C++ 6.0. If, for example, you want to hide the Taskbar, you can use the following code:Ĭopy Code ShowWindow(GetDlgItem(FindWindow( " Shell_TrayWnd", NULL), Hiding the Windows Desktop, Taskbar, Start Button., is generally achieved by passing the window handle returned by FindWindow() to ShowWindow(). The application is a compilation of several sources and I will try to acknowledge the authors whenever possible. Note: I don't claim to be the author of any of the code presented in this article. Although in the end I didn't use any of the techniques described here, I decided to compile all the code in one application for everyone who should need it. The search for ways to achieve this returned several different techniques.

I manage a system where I need to restrict users from accessing the desktop and running other applications. To demonstrate these functions, I also included C and a VB projects.
#HOW TO LOCK COMPUTER WITH KEYBOARD WINDOWS 7 UPDATE#
In response to the many requests from VB (and other languages) coders, I finally took some time to update the project and move all the functions into a DLL so that any program developed in a language capable of calling Windows standard libraries (DLLs) can use them.
