Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Blocking user access to Windows (WH_CBT?)

Posted on 1999-06-27
Medium Priority
Last Modified: 2013-12-03
I am writing an application, during part of which, a client will be answering questions on the screen.  During this time, I don't want the client to be able to access any part of the operating system, or to be able to start up any other program.  I also would like to stop a system restart with ctrl-alt-del.
     I've been reading about hooks, and believe that using the WH_CBT hook will help me accomplish this.  Does anyone know of any code that is already written that would accomplish this?
     I still have some unanswered questions about this.  I read that if the user presses Ctrl-Esc, it terminates the hook.  This key combination also brings up the start menu.  I would also like to block the Ctrl-Esc.  Can I do this with WH_CBT?  How do I block ctrl-alt-del?
     Finally,  the application will likely be a 16 bit app.  I'd like to have this work in both Win 3.1 as well as 95/98 and NT.  Does the DLL have to be a 16 bit DLL to match my application, or a 32 bit DLL to match the operating system.  If the latter is true, then I must find a way for my program to know what environment it is running in so I can call the appropriate DLL.
Question by:NormB062799
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 23

Accepted Solution

chensu earned 300 total points
ID: 1401449
For Windows 3.x

SAMPLE: NoSwitch.exe Prevents Windows from Switching Tasks

For Windows 9x, Windows NT/2000

HOWTO: Disable Task Switching on Win32 Platforms

Expert Comment

ID: 1401450
One thing to note, Chensu's answer will just take care of the ctrl-alt-del, ctrl-esc and alt-tab keys.  In order to not allow new windows to pop up, the only way that I know of is to make a CBT hook...but that would be hard to do..  From what I have heard, the ONLY way you can make sure programs will not start up is by using a VXD(I tried writing a similar program..a lockup program...and I got stuck on the same problem).


Author Comment

ID: 1401451
Thanks for the pointers.  It seems that there are four different solutions recommended, depending on the platform.  I'd like to reduce this all down to one method that could work on all the platforms.  I'm drawn to the keyboard hook described for NT 4.0 SP3 & later.  It seems that I could trap almost any key combination, including hot keys that start up other programs.  Do you think this method would work on the other platforms?  If so, do I write a 16 bit DLL to match my program, or a 32 bit DLL to match to operating system?  Will setting a keyboard hook from a 16 bit app have an effect in a 32 bit OS?

Expert Comment

ID: 1401452
Keep in mind that a keyboard hook will NOT find all open programs.  People can use the mouse to open things up.  =o)

LVL 23

Expert Comment

ID: 1401453
A low-level keyboard hook procedure is supported on Windows NT 4.0 Service Pack 3 and later Windows 2000 only. I don't think you can use only one method for all the platform.

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question