How to Set Foreground/Background Responsiveness in Code

Last reviewed: September 25, 1995
Article ID: Q125660
The information in this article applies to:
  • Microsoft Win32 Application Programming Interface (API) included with:

        - Microsoft Windows NT version 3.5
    

SUMMARY

In Windows NT version 3.5, you can set foreground/background responsiveness by using the System Control Panel in Program Manager. Chose Tasking, then select one of the following through the dialog that is displayed:

  • Best Foreground Application Response Time.
  • Foreground Application More Responsive than Background.
  • Foreground and Background Applications Equally Responsive.

This article describes how to achieve the same thing by using code in a program. It also explains how to override this setting by using code in a program.

MORE INFORMATION

You can use the Registry APIs to set foreground/background responsiveness. The following registry key allows you to specify the priority to give to the application running in the foreground:

   HKEY_LOCAL_MACHINE\SYSTEM
      CurrentControlSet\
      Control\
      PriorityControl\
      Win32PrioritySeparation

The following values are supported:

   Value    Meaning
   ----------------
   0        Foreground and background applications equally responsive
   1        Foreground application more responsive than background
   2        Best foreground application response time

These values correspond to the choices offered in the Tasking dialog described in the "Summary" section of this article.

To override the setting from your application, use SetPriorityClass() to change your application's priority class and SetThreadPriority() to set the priority for a given thread.

NOTE: The thread priority together with the priority class for the process determine the thread's base priority.


Additional reference words: 3.50
KBCategory: kbprg
KBSubcategory: BseProcThrd


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 25, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.