NoSwitch.exe Prevents Windows from Switching Tasks

ID: Q80822


The information in this article applies to:
  • Microsoft Windows Software Development Kit (SDK) versions 3.0, 3.1


SUMMARY

NoSwitch.exe is a sample application that demonstrates how an application can disable the task switch. Certain types of applications, such as security applications and possibly some setup programs, require the ability to disable task switching under Windows. To disable task switching, the program must prevent the user from accessing the Task List, using mouse or keystroke combinations to switch to other applications, and so forth.


MORE INFORMATION

The following files are available for download from the Microsoft Download Center. Click the file names below to download the files:


NoSwitch.exe

For more information about how to download files from the Microsoft Download Center, please visit the Download Center at the following Web address

http://www.microsoft.com/downloads/search.asp
and then click How to use the Microsoft Download Center.

NOSWITCH demonstrates how an application can disable task switching. The application must take the following four steps to disable task switching:

  1. Subclass the desktop window to prevent the Task List from being displayed when the user double-clicks the desktop window.


  2. Prevent the user from using key combinations to switch to another task by trapping the following three wParam values for the WM_SYSCOMMAND message: SC_NEXTWINDOW, SC_PREVWINDOW, and SC_TASKLIST.


  3. Prevent other applications from activating themselves by enumerating all top-level windows, and disabling the windows that do not belong to this application.


  4. Each time a WM_INITMEMUPOPUP message is received for the system menu, disable the menu items that relate to switching tasks.


Before exiting the application, reverse the effects of any actions taken to prevent switching tasks. Refer to the NOSWITCH sample for complete details.

There is a simpler, more limited, method to disable task switching. If the application is run as a maximized window, then step 2 above is enough to prevent switching tasks. However, the application must prevent the window from being restored or minimized. The limitation to this method is that the application must run as a maximized window.

Additional query words:

Keywords : kbfile kbsample kb16bitonly kbGrpUser kbWinOS310 kbWndw kbWinOS300
Version : WINDOWS:3.0,3.1
Platform : WINDOWS
Issue type :


Last Reviewed: December 8, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.